【发布时间】:2019-11-01 16:41:16
【问题描述】:
{
"order_id": 5,
"no": "19000038",
"id": 10,
"name": "John Doe"
}
我使用在线 AES 加密网站对上述数据进行加密,该网站是: https://www.devglan.com/online-tools/aes-encryption-decryption
使用 CBC 模式、256 密钥大小和 Base64 输出文本格式。我在此链接上通过@/backslash-f 复制了操场: AES encryption in swift
以下是我解密加密数据的方法:
let stringData = Data(base64Encoded: stringValue, options: .ignoreUnknownCharacters)
do {
let aes = try AES(keyString: key)
let decryptedData: String = try aes.decrypt(stringData!)
print("String decrypted:\t\t\t\(decryptedData)")
}
catch {
print("Something went wrong: \(error)")
}
数据成功解密,但缺少字符。以下是解密后的数据(如代码中所示):
String decrypted: ,
"order_no": "19000038",
"id": 10,
"name": "John Doe"
}
如您所见,第一个大括号直到 "order_id": 5 丢失。有谁知道为什么会发生这种情况以及如何解决这个问题?
【问题讨论】:
标签: swift encryption aes cbc-mode