One of the requirements in my latest project was to encrypt an image and save it on the device in the application’s sandbox, then decrypt is during runtime and upload it to the server. I looked at the documentation for Apple’s CommonCrypto Framework, but it was taking me plenty of time to implement it so instead i decided to use some wrappers that would get the job done for me. I found the RNCryptor library on Github that uses AES encrypton. It was pretty simple to implement it. First, download the files from its github url and include all the files that are relevant to you present inside the RNCryptor folder on your project. In my case, i just imported all of them for now.
Then use the following code to encrypt the image.
1 2 3 4 5 6 7 8 9 10 11
Note that encryting and decrypting the image requires a passcode (ABC123). To decrypt the image, use the following code ..
1 2 3 4 5 6 7
See, its pretty simple. If you have any questions, let me know in the comments secton below and i will get back to you.