我有一个加密的JSON文件,我正在尝试解密它。我正在使用CryptoSwift框架和AES解密。我有我的钥匙和iv,我必须做" AES-128-CBC"解密。
以下是我的代码:
fileprivate func checkJSONDecryption() {
if let path = Bundle.main.path(forResource: "Questions", ofType: "json") {
print("Inside")
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
let dec = try AES(key: "Key", iv: "IV").decrypt(data.bytes, padding: .zeroPadding)
let decData = NSData(bytes: dec, length: Int(dec.count))
let result = NSString(data: decData as Data, encoding: String.Encoding.utf8.rawValue)
//return
print(String(result ?? "No Data"))
} catch {
// handle error
}
}
}
' dec'代码没有执行。如何解密JSON文件数据或者我遗漏了什么?