Lia*_*iam 3 caching local-storage ios swift
我怎样才能实现安全的本地存储?
目前使用Keychain存储小块数据(即密码),但据我所知,Keychain并不适用于存储较大的数据.
我想要存储的数据示例是具有各种不同属性的NSDictionary类型的消息.
基本上我正在寻找一种在本地但安全地缓存或存储数据的方法.
也许最好找一种自己加密数据的方法?
有没有人对这种方法有什么建议?
您可以使用任何加密算法加密NSDictionary作为json文件在localStorage中
AES是常用的加密算法,它有一个很好的包装器,称为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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1009 次 |
| 最近记录: |