- Encrypt and decrypt an image in a safe and a easy way.
- UIImage, CIImage, image format data(jpeg, png..) supported
- Good performance(0.3 secs taken for encrypting a 8.6MP image on iPhone X)
import ImageCrypto
// encrypt an image
let encryptor = ImageEncryptor()
encryptor.encrypt(data, using: "your key") { result in
switch result {
case .success(let image):
// do what you want with the encrypted image.
case .failure(let error):
print(error)
}
}
// decrypt an image
let decryptor = ImageDecryptor()
decryptor.decrypt(data, using: "your key") { result in
switch result {
case .success(let image):
// do what you want with the encrypted image.
case .failure(let error):
print(error)
}
}
If the encrypted image data change, there’s no way to recover original image.
So never use lossy image format like jpeg for the encrypted image.
- iOS 13.0+
- Swift 5.6
Swift Package Manager : https://github.com/pinkjuice66/ImageCrypto
Jinseok Park
- contact : [email protected]
Distributed under the MIT license. See LICENSE for more information.