1

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 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

2 Comments

I followed option 1, and that's been letting me build and encrypt a db on Windows and then decrypt on Android and interchange. I had been using an older version before. Thanks.
Hi @stephen, I am using the latest version of sqlcipher 3.7 and android app compatible till android 2.1 . I encrypted my already existing database on my mac and tried to decrypt it in android app but it couldn't find any tables but I was able to create new tables and add rows to them. decrypting the same database showed the tables which were existing previously. Any suggestions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.