问题描述
我编译Windows上的sqlite3的命令行shell的SQLCipher版本,并成功创建加密数据库。然后,我想看看我是否能在Android应用程序中使用此premade数据库。我复制数据库的Android应用程序,并试图打电话SQLiteDatabase.openDatabase和我在Windows上使用的密钥通过,但得到了以下内容:
I compiled the SQLCipher version of the sqlite3 command line shell on Windows and successfully created an encrypted database. I then wanted to see if I could use this premade database in an Android app. I copied the database to an Android app and tried to call SQLiteDatabase.openDatabase and passed in the key I used on Windows, but got the following:
引发的:info.guardianproject.database.sqlcipher.SQLiteException:文件加密或不是一个数据库
"Caused by: info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or not a database"
有没有人尝试在Windows上创建一个加密的数据库,然后再打包该数据库与他们的应用?如果是这样,什么是对键控和Android应用程序打开数据库的过程?
Has anyone tried creating an encrypted database on Windows first and then packaging that database with their application? If so, what's the process for keying and opening the database in the Android app?
我看过下面的链接,但还没有找到一个解决方案:
I had read the links below, but hadn't found a solution:
<一个href=\"http://stackoverflow.com/questions/9676905/how-to-read-an-encrypted-database-created-$p$pviously-on-pc-with-sqlcipher-on-and\">How在Android上sqlcipher PC pviously读取加密的数据库中创建$ P $?
推荐答案
如果您使用的是SQLCipher 2命令行程序来创建数据库,你应该:
If you are using the SQLCipher 2 command line program to create the database you should either:
- 使用SQLCipher为Android 2.0.0(https://github.com/sqlcipher/android-database-sqlcipher/downloads);或
- 当使用命令行过,运行PRAGMA cipher_use_hmac = OFF设置键为新数据库后立即禁用HMAC创建数据库。这将创建一个1.1.x版本兼容的数据库,将与SQLCipher工作了Andodi的1.x
这篇关于SQLCipher - 与Android应用程序共享一个Windows创建的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!