databasesqlitesqlcipher

sqlcipher command line not working


I have a encrypted sqlite db and its key. (Which is generated by an android program). However, when I open the db in command line I can not read the db. The command line tool is installed by:

brew install sqlcipher

I open the database by:

sqlcipher EnDB.db
>pragma key="6b74fcd";
>select * from bizinfo;

It keeps telling me "Error: file is encrypted or is not a database"

However, if I open the database file with gui app sqlite database browser (which is a windows program and I run it in wine). It pops up a window for me to enter the key, with 6b74fcd as the key it successfully read the database.

sqlite database browser

As I want to automatically process the db in the future, I can not depend on the GUI. Do you know why the command line is not working?


Solution

  • Solved already!

    after

    pragma key="6b74fcd";
    

    Call this:

    pragma cipher_use_hmac=off;
    

    Then everything works like a charm. It seems the database is a 1.x database.