I'm getting this error while decrypting an AES128CBC encrypted JSON:
assertion failed: Block size and Initialization Vector must be the same length!: file ##### for iOS/CryptoSwift/Sources/CryptoSwift/AES.swift, line 97
I'm using the CryptoSwift Framework with the latest Xcode.
My Method:
func aes128(key: String, iv: String) throws -> String?{
if let aes: AES = try AES(key: key, iv: iv, blockMode: .CBC){
if let encrypted: [UInt8] = try aes.encrypt([UInt8](self.utf8), padding: PKCS7()){
return String(data: NSData.withBytes(encrypted), encoding: NSUTF8StringEncoding)
}
}
return nil
}
Call:
do{
print(try dataStr.aes128("8e0c0e73f97f2eb386ad75ba86051334", iv: "aa17ffc4ea4b1eac8fa0b56872f34e5f"))
}catch{
}
My Method:
The call: