Closed
Description
Hi everyone!
I got an issue when I try to encrypt using TripleDES. I wrote the following function to encrypt data before it's transmitted.
`
func encrypt(_ data: String) -> [UInt8]? {
let key = arrayFrom(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
let blockSize = Cryptor.Algorithm.tripleDES.blockSize()
let plainText = zeroPad(string: data, blockSize: blockSize)
let cryptor = Cryptor(operation: .encrypt, algorithm: .tripleDES, options: [.ECBMode], keyBuffer: key, keyByteCount: key.count, ivBuffer: "")
let cipherText = cryptor.update(byteArray: plainText)?.final()
return cipherText
}`
While I was trying to test it out, I kept running into the following error:
"fatal error: FATAL_ERROR: Invalid key size.: file /Users/admin/Desktop/Hyperwire/Pods/IDZSwiftCommonCrypto/IDZSwiftCommonCrypto/StreamCryptor.swift, line 381"
Do you know how to solve this issue?
Thanks for the help.