2

Currently I can use DB Browser for SQLite to open an encrypted DB file with password on Mac.

DB Browser to open DB

The options as per image:

  • Raw key (start with 0x...)
  • SQLCipher 3 defaults

I would like to open this file using command line instead of DB Browser.

Tried follow commands but seems no luck so far.

sqlcipher xxx.db
SQLite version 3.37.2 2022-01-06 13:25:41 (SQLCipher 4.5.1 community)
Enter ".help" for usage hints.
sqlite> pragma key="0xMyKey";
ok
sqlite> .tables
Error: file is not a database

Appreciate the help in advance so that I can use command line to access or export sqlite db just like mysql (mysql -u ... & mysqldump).

Joe
  • 311
  • 1
  • 2
  • 14

1 Answers1

3

Found the documentation via this link: https://www.zetetic.net/sqlcipher/sqlcipher-api/

sqlcipher xxx.db
SQLite version 3.37.2 2022-01-06 13:25:41 (SQLCipher 4.5.1 community)
Enter ".help" for usage hints.
sqlite> PRAGMA key = "x'{KEY_WITHOUT_0X}'"; // Replace {KEY_WITHOUT_0X} with your key without 0x!
ok
sqlite> PRAGMA cipher_page_size = 1024;
sqlite> PRAGMA kdf_iter = 64000;
sqlite> PRAGMA cipher_hmac_algorithm = HMAC_SHA1;
sqlite> PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1;
sqlite> PRAGMA cipher_default_plaintext_header_size = 0;
sqlite> 
Joe
  • 311
  • 1
  • 2
  • 14
  • This does not work for me. I do not get the "ok" you have when entering the key. I used DB Browser for SQLite on a windows VM and the file could be opened with the same key. Version used is sqlcipher 3.39.4. Any idea why? – Jeff Bencteux Mar 23 '23 at 15:47
  • Can confirm that this works for me on macOS with latest sqlcipher as of today, thanks Joe! – Sai Aug 21 '23 at 18:32