无论如何使用从 NSData 转换的 RNcryptor 来解密 NSString 吗?我不断收到未知的标题错误。这是我正在做的加密:
NSData *data = [@"FeedMeMorePizzaPlease" dataUsingEncoding:NSUTF8StringEncoding];
NSData *encryptedData = [RNEncryptor encryptData:data
withSettings:kRNCryptorAES256Settings
password:@"pizzaHutIsTheWorst"
error:&error];
NSString *encString = [encryptedData base64EncodedStringWithOptions:0];
然后我获取 encString,将其放入服务器上的文本文件中,然后:
NSURL *gUrl = [NSURL URLWithString:@"https://myurlissupersecret.com/cheese.txt"];
NSString *sillyString = [NSString stringWithContentsOfURL:gUrl encoding:(NSUTF8StringEncoding) error:nil];
NSData *blindData = [sillyString dataUsingEncoding:0];
NSData *decryptedData = [RNDecryptor decryptData:blindData withSettings:kRNCryptorAES256Settings password:@"pizzaHutIsTheWorst" error:&error];
有没有办法做到这一点?还是我必须始终加密/解密文件?