demo :
NSData oridata = UIImagePNGRepresentation([UIImage imageNamed:@"QQ20150805"]);
NSLog(@"oridata with public key: %@", oridata);
NSData encdata = [RSA encryptData:oridata publicKey:pubkey];
NSLog(@"Enctypted with public key: %@", encdata);
result:Enctypted with public key: null
demo :
NSData oridata = UIImagePNGRepresentation([UIImage imageNamed:@"QQ20150805"]); NSLog(@"oridata with public key: %@", oridata); NSData encdata = [RSA encryptData:oridata publicKey:pubkey]; NSLog(@"Enctypted with public key: %@", encdata);
result:Enctypted with public key: null
调试发现进入如下if语句里,不知为何?因为图片数据比较大? size_t outlen = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t); if(srclen > outlen - 11){ CFRelease(keyRef); return nil; }