How to use encryption to SQLite DB in Delphi if i'm using SQLite ODBC Driver.
I must use ADO components for data access.
SQLite doesn't support encrypting database files by default. Instead, you need to use a modified version of SQLite like SEE, SQLCipher, SQLiteCrypt, or wxSQLite3.
One solution is to export/backup to a [well-defined] XML format or a "fake structured" SQLite database file. Or to encrypt the back-up database (e.g. in ZIP+password). Or just change the file extension (this will work for most people I'd imagine).
SQLite has hooks built-in for encryption which are not used in the normal distribution, but here are a few implementations I know of: SEE - The official implementation. wxSQLite - A wxWidgets style C++ wrapper that also implements SQLite's encryption. SQLCipher - Uses openSSL's libcrypto to implement.
SQLCipher does not implement its own encryption. Instead it uses the widely available encryption libraries like OpenSSL libcrypto, LibTomCrypt, and CommonCrypto for all cryptographic functions.
As I see from ODBC driver source, one of the 2 options:
WITH_SQLITE_DLLS
defined, so it will use sqlite3.dll. Then provide sqlite3.dll compiled with SQLITE_HAS_CODEC
.SQLITE_HAS_CODEC
defined. Then link SQLite engine statically with ODBC driver.SQLITE_HAS_CODEC
means, that SQLite engine is compiled with build-in codec. By default SQLite has no codec. You can use SQLCipher instead of standard SQLite. Or obtain SQLite with Encryption Extension.
Then to connect to encrypted database using ODBC you will need to specify PWD=xxx
in connection string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With