0
看到我的代碼:緩衝區太小的SecKeyWrapper,如何解決它?
NSString *requestString = @"I am an encrypted piece of dataaaaaaaaaaaaaaaaaaaa";
NSData *xmlDaCriptare1 = [NSData dataWithBytes:[requestString UTF8String] length:[requestString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
xmlDaCriptare1 = [requestString dataUsingEncoding:NSUTF8StringEncoding];
NSString *strcheck = [[NSString alloc] initWithData:xmlDaCriptare1 encoding:NSUTF8StringEncoding];
NSLog(@"%@", strcheck);
char *keya = "a16byteslongkey!";
NSData * symmetricKey = [NSData dataWithBytes:keya length:16];
CCOptions pad = kCCOptionECBMode;
NSData *xmlCriptato = [[SecKeyWrapper sharedWrapper] doCipher:xmlDaCriptare1
key:symmetricKey
context:kCCEncrypt
padding:&pad];
它總是返回:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Problem with encipherment ccStatus == -4301'
這就是 「緩衝區太小」。任何人都知道如何解決它? 謝謝, 奧蕾莉亞
謝謝你。我試圖看到代碼,但沒有成功。方法是 - (NSData *)doCipher:(NSData *)plainText key:(NSData *)symmetricKey context:(CCOperation)encryptOrDecrypt padding :(CCOptions *)pkcs7 { – Alleria