Version 1 of How To encrypt a SQLite database in Tcl under Windows

Updated 2010-11-15 22:39:03 by HJG

SQLite does not support encryption or passwords. There are a few extensions that add the capability for encryption, among these are The SQLite Encrytion Extension (SEE), SQLite-Crypt, wxsqlite3 and SQLCipher. However none of these provides with the tcl bindings to be able to manipulate an SQLite database from tcl code.

I will show you how to achieve this, but it will take a bit of work. You need to download MinGW/MSYS, OpenSSL and the SQLCipher source code. After that follow these steps:

1 - install MinGW/MSYS

2 - install OpenSSL (requires Visual C++ 2008 Redistributables)

3 - create an sqlcipher directory and place all the files from the SQLCipher zip

4 - copy openSSL/bin/libeay32.dll to sqlcipher directory.

5 - copy openSSL/lib/MinGW to /MinGW/lib directory.

6 - go to the sqlcipher directory and compile using the following command:

./configure CFLAGS="-DSQLITE_HAS_CODEC -I/c/openssl/include" LDFLAGS="-leay32 -L/c/openssl/lib"

7 - type make

8 - type make dll

These will create an sqlite3.exe and sqlite3.dll with tcl bindings.

When trying to encrypt a database just type: PRAGMA key = 'password'

That's all.