ios - 为什么 decrytedText 为 NULL?
问题描述
我的应用从 GET 请求中接收加密数据。我在解密数据时遇到问题。我正在使用跨平台的 CryptLib 库CryptLib。遵循 CryptLib.m 中的文档,但似乎没有任何效果。如果有人对 CryptLib 有所了解,将不胜感激,请在下面查看我的代码。
代码
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:
^(NSData * _Nullable encryptedData,
NSURLResponse * _Nullable response,
NSError * _Nullable error) {
//has data
NSString *jsonData = [[NSString alloc] initWithData:encryptedData encoding:NSUTF8StringEncoding];
NSLog(@"Data received: %@", jsonData);
NSString *key = @"3HS5UtP7hEc5Jsqg7P4KDQEH2y95v92Z";
NSString *iv = @"ZkjH27Rh63RQtH8y";
//Decrypted data is NULL!
encryptedData = [[StringEncryption alloc] decrypt:encryptedData key:key iv:iv];
NSString * decryptedText = [[NSString alloc] initWithData:encryptedData encoding:NSUTF8StringEncoding];
NSLog(@"decrypted data:: %@", decryptedText); //print the decrypted text
}] resume];
解决方案
推荐阅读
- google-analytics - 在 Bigquery 中访问主页后找出用户的第二页
- angular - 调用 PUT web api:跨域请求阻塞问题
- java - jpa 实体 bean 的默认范围是什么?它有什么帮助?
- ruby-on-rails - 如何在 Rails 中覆盖 mongoid 客户端
- machine-learning - 我们如何在 Windows 中使用英特尔 Movidius 神经计算棒来定制模型
- vba - 我对撇号的查询和使用是否正确?
- r - R:如何计算数据帧的每个值与同一行中另一个数据帧的所有元素之间的差异?
- protocol-buffers - Is there an option to import services from other proto files?
- javascript - How can i apply multiple filters and multiple value in JS?
- asp.net-core - 如何在 ASP.NET Core mvc 中的模型绑定上将字符串转换为值类型