I'm trying to encrypt/decrypt image using CryptoSwift.
I converted the image to JPEG format then to Data then to String to be the input of CryptoSwift. I got the encryptedString and decrypted it into decryptedString.
Is there a way to convert the decryptedString into JPEG format so I can view it in UIImageView?
Here is my code:
guard let image = UIImage(named: "img") else { return }
let data = UIImageJPEGRepresentation(image, 1.0)
let character = CharacterSet ()
let str = NSData.init(data: data!)
let text = str.description.trimmingCharacters(in:character).replacingOccurrences(of: " ", with: "")
let plainText = text
let key = "simplekey"
let iv = "1234123412341234"
let cryptoLib = CryptLib();
let encryptedString = cryptoLib.encryptPlainText(with: plainText, key: key, iv: iv)
let decryptedString = cryptoLib.decryptCipherText(with: encryptedString , key: key , iv: iv)`