SQLCipher Extension

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
felixbrueckner
Posts: 5
Joined: Fri 06 Dec 2013 18:20

SQLCipher Extension

Post by felixbrueckner » Mon 04 Aug 2014 11:43

Hi there,

in your release notes for Version 5.2.171.0 you mention that the SQLCipher Extension is supported.

We are currently using SQLiteCrypt for the enryption of SQLite files with dotConnect for SQLite and would like to migrate to SQLCipher.

How do we use this new SQLCipher Extension in practice? Any samples (C# code) available? We use Entity Framework 6.1 with code first.

Do we need to buy the ADO.NET driver for SQLCipher or the pure DLL to let it work with dotConnect for SQLite? What is the correct connection string entry to use the SQLCipher Extension?

Thanks and regards
Felix
Last edited by felixbrueckner on Wed 06 Aug 2014 10:49, edited 1 time in total.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: SQLCipher Extension

Post by Shalex » Mon 11 Aug 2014 16:49

The way how to use SQLCipher extension with dotConnect for SQLite:

1. By default, dotConnect for SQLite installs and uses a predefined library (C:\Windows\System32\sqlite3.dll) without SQLCipher extension. So you should replace this library with the one which includes the corresponding extension. For this, download sources (and compile) or buy a compiled SQLite.Interop.dll at http://sqlcipher.net/. Rename SQLite.Interop.dll to sqlite3.dll and replace C:\Windows\System32\sqlite3.dll with it.
Take into account:
a) the capacity (x86 or x64) of SQLite.Interop.dll (sqlite3.dll) should be the same as the capacity of your application
b) sqlite3.dll included with the dotConnect to SQLite is compiled with SQLITE_ENABLE_COLUMN_METADATA defined. It allows using sqlite3_column_database_name, sqlite3_column_table_name, and sqlite3_column_origin_name functions, which are necessary for building correct DML statements for a result set with aliases used. If you want to build an engine library yourself, you need to download its sources and compile it with SQLITE_ENABLE_COLUMN_METADATA defined.

2. Now add the "Encryption=SQLCipher;" entry to the connection string and use a connection like you do before (plain ADO.NET or via Entity Framework):

Code: Select all

SQLiteConnection conn = new SQLiteConnection(@"DataSource=d:\SQLite\deptEmpEnq.db;Encryption=SQLCipher;Password=test");
      conn.Open();

felixbrueckner
Posts: 5
Joined: Fri 06 Dec 2013 18:20

Re: SQLCipher Extension

Post by felixbrueckner » Wed 13 Aug 2014 07:28

Great, many thanks for this explanation!

Felix

Post Reply