Encrypting SQLite database file on iOS
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 Dat开发者_开发知识库a)
http://support.apple.com/kb/HT4175Please correct me if I'm wrong, the file will be encrypted so no one will be able to crack into it (although it will be possible for a determined cracker I think).
Core Data queries will run as usual right? I mean there is no performance penalty neither a different API.
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
精彩评论