SQLCipher - Sharing a Windows-created database with an Android application

旧街凉风 提交于 2019-12-11 09:43:48

问题


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:

"Caused by: info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or not a database"

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:

https://groups.google.com/group/sqlcipher/browse_thread/thread/d2694975e8f3809f

How to read an encrypted database created previously on pc with sqlcipher on android?


回答1:


If you are using the SQLCipher 2 command line program to create the database you should either:

  1. Use SQLCipher for Android 2.0.0 (https://github.com/sqlcipher/android-database-sqlcipher/downloads); or
  2. When creating a database using the command line too, run PRAGMA cipher_use_hmac = OFF immediately after setting the key for the new database to disable HMAC. This will create a 1.1.x compatible database that will work with SQLCipher for Andodi 1.x


来源:https://stackoverflow.com/questions/9742686/sqlcipher-sharing-a-windows-created-database-with-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!