使用SQLCipher与Android运SQLite数据库文件 [英] using SQLCipher with android shipped sqlite database file
问题描述
我在资产数据库文件重置
文件。
我如何使用 SQLCipher
在Android上的数据库进行加密?
How can I use SQLCipher
to encrypt the database in android?
推荐答案
这将是一个有点复杂。由于数据库文件格式为SQLite和SQLCipher为Android之间是不同的,因为你想出货的未加密的数据库,你将不得不做一些事情。
This is going to be a bit complicated. Since the database file format is different between SQLite and SQLCipher for Android, and since you want to ship an unencrypted database, you will have to do a few things.
首先,我会得到 SQLiteAssetHelper
去,为客户提供未加密的数据库环境。
First, I'd get SQLiteAssetHelper
going, to deliver the unencrypted database to your environment.
然后,使用标准SQLCipher为Android创建一个空的,但是加密的数据库。
Then, use standard SQLCipher for Android to create an empty-but-encrypted database.
接下来,您将需要实现code复制数据进行包装,但是,未加密的数据库,并将其插入到空的,但是加密的数据库。
Next, you will need to implement the code to copy the data out of the packaged-but-unencrypted database and insert it into the empty-but-encrypted database.
一旦做到这一切完成后,您可以关闭并删除包装,但是,未加密的数据库,只是使用的加密之一。
Once that is all done, you can close and delete the packaged-but-unencrypted database and just use the encrypted one.
这可能使一个有用的扩展,以 SQLiteAssetHelper
,有一天...
This might make a useful extension to SQLiteAssetHelper
, someday...
这篇关于使用SQLCipher与Android运SQLite数据库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!