加密/解密SQLite数据库并使用它“即时” [英] Encrypt/Decrypt SQLite-database and use it "on the fly"

查看:152
本文介绍了加密/解密SQLite数据库并使用它“即时”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是:
在我的Qt4.6项目中,我使用SQLite数据库。这个数据库不能在我的硬盘驱动器上加密。所以我想要的是,在我的程序的每一个开始,用户被要求输入密码来解密数据库。当然数据库从来不应该出现在我的硬盘驱动器上的没有加密(不加密)。

那么有没有可能即时解密一个SQLite数据库,并读写数据?什么算法是最好的(可能是AES)?

当不可能(或非常慢)时,也许最好是加密数据库中的每个字符串,并在密码正确时解密字符串(这样一个用户可以打开数据库,但不知道所有的条目是什么意思)?

Here's the thing: In my Qt4.6-Project, I use a SQLite-Database. This database shouldn't be unencrypted on my harddrive. So I want, that on every start of my program, the user gets asked to enter a password to decrypt the database. Of course the database never should appear "in clear" (not encrypted) on my harddrive.
So is there any possibility to decrypt a SQLite-database "on the fly" and read and write data? What algorithm is here the best (maybe AES)?
When it's not possible (or very slow), maybe it's better to encrypt every string in the database and decrypt the string when the password was right (so that a user could open the database, but has no clue what all the entrys could mean)?

推荐答案

没有内置的支持,那就是说你有选择。

There is no built in support, that being said you do have options.

1)你可以自己加密/解密所有的字符串,但这是很多工作,不透明,不允许你做数据库中的搜索。

1) You can encrypt/decrypt all of your strings yourselves, but this is a lot of work, is not transparent, and won't allow you to do things like searching in the database.

2) SQLiteCrypt SQLCipher 做你正在看的对于。

2) SQLiteCrypt and SQLCipher do what you're looking for.

您可以使用它们几乎完全透明,通常它们在没有加密的情况下只占用大约5%的开销。

You can use them almost entirely transparent and typically they are said to have only about 5% overhead compared without encryption.

这篇关于加密/解密SQLite数据库并使用它“即时”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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