我正在加密视频,有时我会遇到 CCCrypt 崩溃。这是我的加密方法,谁能解释它为什么会崩溃?(该过程在队列中的 NSOperation 中运行)。崩溃发生CCCryptorStatus cryptStatus = CCCrypt
在线
char *key = MY_ENCRYPTION_KEY;
NSUInteger dataLength = [data length];
uint8_t encryptedData[dataLength + kCCBlockSizeAES128];
size_t encryptedLength;
size_t encryptedDataLength = dataLength + kCCBlockSizeAES128;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionECBMode|kCCOptionPKCS7Padding, key, kCCKeySizeAES128, NULL, [data bytes], dataLength, encryptedData, encryptedDataLength, &encryptedLength);
if(cryptStatus == kCCSuccess)
{
NSData *output = [[NSData alloc] initWithBytes:encryptedData length:encryptedLength];
completionBlock(nil, output);
} else {
NSError *error = [[NSError alloc] initWithDomain:@"Error encrypting" code:-999 userInfo:nil];
completionBlock(error, nil);
}