Command line Decryption of a SQLite Database Encrypted with GRDB + SQLCipher #1517
Replies: 1 comment 1 reply
-
Hello @franciskelly-okta,
This "file is not a database" error is indeed the sign of a database that could not be decrypted. There are at least two tests (1, 2) in GRBD that asserts that a database encrypted from GRDB apis can be attached with
When GRDB is compiled with SQLCipher, it always runs Now, both SQLCipher itself, and apps, can do stuff. The version of SQLCipher is important. For example, SQLCipher 4 has to be given special instructions to decode databases encrypted with SQLCipher 3 (see Also, apps can instruct GRDB to configure SQLCipher: var config = Configuration()
config.prepareDatabase { db in
// The minimum statement that encrypts:
try db.usePassphrase("secret")
// Apps can invoke other SQLCipher config that impact your use case:
try db.execute(sql: """
PRAGMA cipher_page_size = ...;
PRAGMA kdf_iter = ...;
PRAGMA cipher_plaintext_header_size = ...;
PRAGMA cipher_salt = ...;
...
""")
} Note that some apps don't use the var config = Configuration()
config.prepareDatabase { db in
// Some people prefer that for security reasons because they
// can manage the lifetime of the key bytes.
sqlite3_key(db.sqliteConnection, ...)
} I guess you need to gather more information about your encrypted database. |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if anyone can advise me on how to use SQLCipher on the command line or a Python script using the sqlcipher library to decrypt a database encrypted with GRDB + SQLCipher. I can write a simple Swift app that takes the hex key and the path to database file and I can successfully dump the database to the console. But If I try either the
ATTACH
command or thePRAGMA key =
command to try to decrypt the database from the command line (using the sqlcipher command), I get the "file is not database" error (error 26).My assumption is that GRDB has some settings baked in that are different than SQLCipher defaults and that is causing the problem for me. I'm using GRDB 6.20.2 and SQLCipher 4.5.5.
I can make do with my Swift app, but it would be nice to be able to use command line tools as well.
Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions