I have one SQL database file in my bundle. I need to encrypt that file using AES-256 and need to write this data to another file.
I have already tried to use RNCryptor and CryptoSwift as well but, I am to getting exact solutions for my problem.
Just read any file as Data
or NSData
instance and apply encryption to that and write back with a custom extensions may be.. You can use the lib suggested by @Ashish Rana or https://gist.github.com/hfossli/7165dc023a10046e2322b0ce74c596f8
Load data from file
guard let fileURL = Bundle.main.url(forResource: "file-to-be-encrypted", withExtension: "txt") else { return }
guard let fileData = try? Data(contentsOf: fileURL) else { return }
Apply encryption
let encrypted = try aes.encrypt(digest)
Save encrypted file back
try encrypted.write(to: encURL)
If you do not want to share the encrypted file and just want to secure it then you can use OS base encryption like mentioned here: https://www.tomsguide.com/us/how-to-encrypt-ios,news-18338.html