Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top