when I encrypt a file(doc, pdf, etc.), I use:
size_t bufferSize = dataLength + kCCBlockSizeAES128;
CCCrypt( kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
keyPtr, kCCKeySizeAES256,
NULL /* initialization vector (optional) */,
dataBytes, dataLength, /* input */
buffer, bufferSize,/* output */
&numBytesEncrypted );
when decrypt, I use:
size_t bufferSize = dataLength + kCCBlockSizeAES128;
CCCryptorStatus result = CCCrypt( kCCDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
keyPtr, kCCKeySizeAES256,
NULL /* initialization vector (optional) */,
dataBytes, dataLength,/* input */
buffer, bufferSize,/* output */
&numBytesEncrypted );
But when decrypt, it returns error:kCCDecodeError = -4304.
If I remove the param of kCCOptionPKCS7Padding when decrypt, there is no error. But the file cannot open either.
So, could u tell me how to pass these params?
thanks alot!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…