I am getting CCCryptorStatus as kCCSuccess.
This means encryption is done successfully.
However, I want to get encrypted data, how to get it?
Any help will be appreciated.
Thanks,
Puja Rathod
I am getting CCCryptorStatus as kCCSuccess.
This means encryption is done successfully.
However, I want to get encrypted data, how to get it?
Any help will be appreciated.
Thanks,
Puja Rathod
Take a good look at the arguments of CCCrypt:
CCCryptorStatus CCCrypt(CCOperation op,
CCAlgorithm alg,
CCOptions options,
const void *key,
size_t keyLength,
const void *iv,
const void *dataIn,
size_t dataInLength,
void *dataOut,
size_t dataOutAvailable,
size_t *dataOutMoved);
(This is from an old man page which uses C types.)
With the last three arguments, you must provide:
In Objective-C, you can use NSMutableData for providing the necessary buffer (code example taken from here):
CCCryptorStatus ccStatus = kCCSuccess;
size_t cryptBytes = 0;
NSMutableData *dataOut = [NSMutableData dataWithLength:dataIn.length + kCCBlockSizeAES128];
ccStatus = CCCrypt(encryptOrDecrypt, // kCCEncrypt or kCCDecrypt
kCCAlgorithmAES128,
kCCOptionPKCS7Padding,
key.bytes,
kCCKeySizeAES128,
iv.bytes,
dataIn.bytes,
dataIn.length,
dataOut.mutableBytes,
dataOut.length,
&cryptBytes);
dataOut.length = cryptBytes;