Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypting SQLite database in Delphi OLEDB

How to use encryption to SQLite DB in Delphi if i'm using SQLite ODBC Driver.
I must use ADO components for data access.

like image 796
Artem Zubkov Avatar asked Jan 17 '12 05:01

Artem Zubkov


People also ask

Can you encrypt a SQLite database?

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.

How do I make SQLite secure?

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).

What encryption does SQLite use?

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.

What encryption does SQLCipher use?

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.


1 Answers

As I see from ODBC driver source, one of the 2 options:

  1. Compile ODBC driver with WITH_SQLITE_DLLS defined, so it will use sqlite3.dll. Then provide sqlite3.dll compiled with SQLITE_HAS_CODEC.
  2. Compile ODBC driver and SQLite engine with 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.

like image 176
da-soft Avatar answered Oct 15 '22 17:10

da-soft