下面,
NSString * decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
它在iPhone设备上运行不佳。我收到错误消息 - [__ NSArrayM insertObject:atIndex:]:object不能为nil '。 请帮助我。
这是我的代码
NSString *stringIndex1 = [[NSString alloc]init];
NSMutableArray *arrAthigaaramList1 = [[NSMutableArray alloc] init];
dictDecryptList=[[NSMutableDictionary alloc]init];
for(int i=0;i<[arrD_Chapter count];i++)//50 Chapter wise
{
stringIndex1 = [arrD_Chapter objectAtIndex:i];
NSData *b64DecData = [Base64 decode:stringIndex1];
NSData *decryptedData = [[NSData alloc]init];
decryptedData= [b64DecData AESDecryptWithPassphrase:@"mypassword"];
NSString *decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSUTF32StringEncoding];
if (decryptedStr) {
NSLog(@"Decryped Data Base 64 encoded = %@",decryptedStr);
[arrAthigaaramList1 addObject:decryptedStr];
} else {
NSLog(@"ERROR decrypting!!!");
}
}
答案 0 :(得分:1)
更改这些行:
NSData *decryptedData = [[NSData alloc]init];
decryptedData= [b64DecData AESDecryptWithPassphrase:@"mypassword"];
NSString *decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSUTF32StringEncoding];
到此:
NSData *decryptedData= [b64DecData AESDecryptWithPassphrase:@"mypassword"];
if([decryptedData length] > 0)
{
NSString *decryptedStr = [[NSString alloc] initWithData:decryptedData
encoding:NSUTF32StringEncoding];
} else {
NSLog(@"Hmmm, why is decrypted data a zero byte object??");
}