在iOS上加密SQLite数据库文件 [英] Encrypting SQLite database file on iOS

查看:791
本文介绍了在iOS上加密SQLite数据库文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户询问我是否可以加密他的iOS SQLite文件。

我检查了这两个资源:



加密和解密Sqlite文件(使用核心数据)

< a href =http://support.apple.com/kb/HT4175 =nofollow> http://support.apple.com/kb/HT4175



请纠正我,如果我错了,该文件将被加密,所以没有人能够破解它(虽然这将是可能的一个确定的饼干我想)。



核心数据查询会照常运行吗?

解决方案

您提供的链接涉及在整个设备上加密存储;然而,如果目标是用户不能直接打开数据库文件,将不会帮助你,因为防止的唯一的事情是你的数据被访问时,设备被盗。它也依赖于用户设置它,应用程序不能授权设备存储加密。



基本上,什么是想要存储加密的动机? / p>

编辑:



基于响应链,我认为使用SQLLite的加密变体:



http://sqlcipher.net/



是一个很好的解决方案。这将加密数据库内容,在他们打到存储,这是伟大的。攻击者仍然可能能够找到您的代码中用于解密数据库的密钥,但您可以添加的任何防御层将有所帮助。我不认为你可以使用CoreData(因为它是建立在内置的sqllite库的顶部),但你可以使用它与一个封装,如FMDB:



https://github.com/ccgus/fmdb


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://support.apple.com/kb/HT4175

Please 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

这篇关于在iOS上加密SQLite数据库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆