SQLite and Encryption

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
colboy
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 21.11.2008, 21:48

SQLite and Encryption

Post by colboy »

I found the [link="http://zeos.firmos.at/kb.php?mode=article&k=14"]knowledgebase[/link] article for using encryption in ZEOS 6.6.4, but still can't seem to get it to work. I create a new project, save it to disk, make sure the .NET Sqlite DLL is in the same directory, set the Zconnection protocol to sqlite-3 and the database property pointing to the database, and have the following code attached to a button:

Code: Select all

   zconnection1.Properties.Clear;
   ZConnection1.password:='letmein';
   ZConnection1.Properties.Add('encrypted=true');
   ZConnection1.Connect;
   ZTable1.TableName:='Lawyers';
   ZTable1.Active:=true; 
but when I run it says "SQL Error: file is encrypted or is not a database"

Does anybody have an idea what I am doing wrong? The knowledgebase article mentions about setting the Parameter to 'encrypted=true' however I can find no Parameter property, the nearest thing is Properties. I also notice in the knowledgebase article it mentions about manually running the .Key method, but how do I get to it?

Many thanks in advance. Colin.
colboy
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 21.11.2008, 21:48

Post by colboy »

Does no body have any pointers? I know all the supporting stuff is there, I just can't work out how to access it. Colin
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Does the dll you use support encryption in the first place, or is it the standard sqlite dll, which doesn't have these encryption facilities?

Mark
Image
colboy
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 21.11.2008, 21:48

Post by colboy »

Yes, I have the required DLL as outlined in the Knowledge base. I'm assuming that .KEY method is called when the database is opened, but that doesn't appear to be the case and I can't work out how to call it myself. Colin
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Can you debug the TZSQLiteConnection.Open procedure in ZDbcSQLite.pas?

There you should find out if the FPlainDriver.Key call is done or not. If not : why? If yes : was it executed successfully?

Mark
Image
colboy
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 21.11.2008, 21:48

Post by colboy »

Thanks for your help, I found the issue. During development I had the database open in SQLiteExpert, which prevented my program from opening it. Must be something to do with the encryption, as I've had the same database open in several different pieces of software before.

Colin
Post Reply