How could I implement secure local storage?
Currently using the Keychain to store small pieces of data (i.e. Password), however, as far as I am aware Keychain is not meant for storing larger data.
An example of data I am looking to store is a message of NSDictionary type with various different properties.
Essentially I am looking for a way to cache or store data locally but securely.
Perhaps it would be better to find a way to encrypt the data myself?
Does anyone have any suggestions as to what the approach would be?
You could save the NSDictionary as json file in your localStorage by encrypting using any encryption Algorithm
AES is on of the commonly used encryption algorithm and there is an excellent wrapper for it called RNCryptor
https://github.com/RNCryptor/RNCryptor
var data = NSkeyedArchiver.archiveRootObject(yourDictionary)
let password = "Secret password"
let ciphertext = RNCryptor.encryptData(data, password: password)
ciphertext.writeToFile(yourPath , atomically:true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With