I have a encrypted JSON file and I am trying to decrypt it. I am using CryptoSwift framework and AES decryption. I have my key and iv for that and I have to do "AES-128-CBC" decryption.
Below is my code:
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
}
}
}
After 'dec' code is not executing. How can I decrypt that JSON file data or I am missing something?