I am integrating the CryptoSwift and found this error "Member 'CBC' takes no arguments".
I am calling the function like this
let enc = try! AES(key: key, blockMode: .CBC(iv: iv)).encrypt(self.arrayOfBytes())
I am integrating the CryptoSwift and found this error "Member 'CBC' takes no arguments".
I am calling the function like this
let enc = try! AES(key: key, blockMode: .CBC(iv: iv)).encrypt(self.arrayOfBytes())
Sorry I'm a little late, but just encountered this issue after running pod update
. I was doing the same as you and my project broke after the update, since the new API introduces changes that are not backward compatible. To answer your question, now CBC is not a member of the BlockMode enum, so the correct way to write equivalent code with the new API is:
let enc = try! AES(key: key, blockMode: CBC(iv: iv)).encrypt(self.arrayOfBytes())
If you're looking at the CryptoSwift API for version 3 you get the following initializer for AES:
public init(key: Array<UInt8>, iv: Array<UInt8>? = nil, blockMode: BlockMode = .CBC, padding: Padding = PKCS7()) throws {
As you can see the iv
here is not a parameter of CBC - as it should be - but of the block cipher itself. You should either upgrade to Swift 4 or you should adhere to the older API.
For the Swift 3.2 you should check the correct README for the API usage, as the API changed over the time.
Here is the README for Swift 3.2 (swift32 branch): https://github.com/krzyzanowskim/CryptoSwift/tree/swift32#aes-advanced-usage
To answer the question, this is the proper form for your needs:
try AES(key: key, iv: iv, blockMode: .CBC, padding: PKCS7())