Hi,
I've searched the group for all the keywords I can think of, and have
only come up with the references to Noah's Wiki with the 3 steps to
transparent encryption here...
http://groups.google.com/group/csharp-sqlite/browse_thread/thread/2704ff8e5d5738df#
I have finally managed to encrypt and access an encrypted database,
but only under the following circumstances. I wonder if the
observations I have indicate I was doing something incorrectly, or
whether they warrant further explanation on the Wiki.
Step 1 - Compile with SQLITE_HAS_CODEC
Not a problem, since the DLLs we use in our project have had that
option from Day 1.
Step 2 - Activate encryption with a pragma command similar to:
PRAGMA hexkey="0x0102030405060708090a0b0c0d0e0f10"
It may be my relative novice status with string handling in VB.Net
but, since the whole has to be passed as CommandText to the
SQLiteCommand used to 'issue' the PRAGMA, I have only ever got this to
work with single quotes around the hexkey value, as in:
Dim cmdEncrypt As New SqliteCommand("PRAGMA hexkey='" + myHexKey +
"'", mcnn)
I also had to issue a .Open on the connection before the PRAGMA,
despite Step 2 coming before Step 3!
I thought I had issues with terminating the hexkey PRAGMA with a semi-
colon as we have with the others we issue (cmdFKstate.CommandText =
"PRAGMA foreign_keys = ON;"). I used the code in
SQLiteClientTestDriver.cs (//Issue 76) as a guide to what was
expected, but it seems now that the semi-colon may either be present
or not.
The most drastic discovery seemd to be that I could not encrypt a
populated database - only a new one before I loaded the schema. Is
this correct, or should supplying the hexkey PRAGMA to an unencrypted
database encrypt it?
Step 3 - Open or attach the databse.
Place before Step 2!!
Keep up the great work!