Encrypting SQLite database file on iOS

后端 未结 1 1180
长发绾君心
长发绾君心 2020-12-15 02:27

My client asked me if it is possible to encrypt his iOS SQLite file.
I checked this two resources:

Encrypt & Decrypt Sqlite file (Using Core Data)
http

相关标签:
1条回答
  • 2020-12-15 02:51

    The links you provided talk about encrypting storage across the whole device; However if the goal is that the user not be able to open the database file directly then will not help you, as the only thing that protects against is your data being accessed in the event the device is stolen. It also relies on the user to set it up, the app cannot mandate that the device storage is encrypted.

    Basically, what is the motivation behind wanting the storage encrypted?

    EDIT:

    Based on the response chain, I think using the encrypted variant of SQLLite at:

    http://sqlcipher.net/

    is a good solution. This encrypts database contents before they hit storage, which is great. An attacker still might be able to find the key used in your code to decrypt the database, but any layer of defense you can add will help. I don't think you could use that with CoreData (as it is built atop the built-in sqllite libraries) but you could probably use it with a wrapper like FMDB:

    https://github.com/ccgus/fmdb

    0 讨论(0)
提交回复
热议问题