Here's the necessary process if you currently want to use CommonCrypto pod:
- make sure to include the pod in your Rakefile or perform the equivalent Bundler ritual
- don't forget to include app.frameworks << 'Security' in the Rakefile as well
- then go to vendor/Pods/CommonCrypto and delete the file example.m
Congratulations, you're all set!
Here's a quick (and dirty) sample:
iv = 'init_vector_here'
key = 'key_here'
plainText = 'This is plain text'
plainData = plainText.dataUsingEncoding(NSUTF8StringEncoding)
ivData = iv.dataUsingEncoding(NSUTF8StringEncoding)
keyData = key.dataUsingEncoding(NSUTF8StringEncoding)
status = NIL
result = plainData.dataEncryptedUsingAlgorithm(0, key: keyData, initializationVector: ivData, options: 0, error: status) # 0 = AES128
p result.base64EncodedString
For Base64 encoding you have to include the 'NSData+Base64' pod.
Thank you @AwDogsGo2Heaven and @Jamon Holmgren for your helpful suggestions!