* * *

Author Topic: [Solved] encrypted sqlite using wxsqlite  (Read 1051 times)

xaver13

  • Jr. Member
  • **
  • Posts: 85
[Solved] encrypted sqlite using wxsqlite
« on: February 14, 2018, 11:01:12 am »
hello, I would like to use transparent encryption on sqlite.

I found sqlcipher and wxsqlite.

I downloaded sqlite3.dll from
https://github.com/utelle/wxsqlite3/releases
and simply overwrote the standard dll.

I use my sample project. Everything continues working. Nice.
And now I want to encrypt a database.

When I tried to do it using
 
Code: Pascal  [Select]
  1.      
  2. SQLiteConnection1.ExecuteDirect('UserAdd(wxT("testuser"), wxT("testpswd"), true) ');
  3. SQLiteConnection1.ExecuteDirect('UserLogin(wxT("sampleuser"), wxT("samplepswd")) ');
  4.  
   
I got syntax error near "UserAdd", what a surprise!  :D

At least the wxT function is unknown.
Does anybody tried to use  Wxsqlite in Lazarus successfully and knows how to do it?
Thank you for help.                       



« Last Edit: February 15, 2018, 10:35:54 am by xaver13 »
--
Jiri Cvrk

rvk

  • Hero Member
  • *****
  • Posts: 3450
Re: encrypted sqlite using wxsqlite
« Reply #1 on: February 14, 2018, 12:05:20 pm »
I don't think UserAdd() is an SQL command. So you can't just use it with ExecuteDirect(). You'll need to implement the extra DLL functions in your source code.

The wiki does mention some support for encryption.
Quote
In recent FPC versions (implemented March 2012), SQLDB included support for some extended versions of SQLite3 which encrypt the SQLite database file using the AES algorithm. Use the password property to set the encryption key.
http://wiki.freepascal.org/SQLite

xaver13

  • Jr. Member
  • **
  • Posts: 85
Re: encrypted sqlite using wxsqlite
« Reply #2 on: February 14, 2018, 12:29:00 pm »
there is some sample code there https://github.com/utelle/wxsqlite3/blob/master/samples/minimal.cpp

but it is in cpp and uses some cpp wxsqlite3 libraries.
Has anybody solved this in Pascal?
--
Jiri Cvrk

rvk

  • Hero Member
  • *****
  • Posts: 3450
Re: encrypted sqlite using wxsqlite
« Reply #3 on: February 14, 2018, 12:51:12 pm »
Do you need user authentication or do you just need encryption?

Just using encryption should be transparent and you don't need any extra code (other than the encryption key).

xaver13

  • Jr. Member
  • **
  • Posts: 85
Re: encrypted sqlite using wxsqlite
« Reply #4 on: February 14, 2018, 01:54:36 pm »
hello, thank you, only encryption is needed.

Uff. I need nothing. I set only password property and it is working!  :)
« Last Edit: February 14, 2018, 02:02:32 pm by xaver13 »
--
Jiri Cvrk

rvk

  • Hero Member
  • *****
  • Posts: 3450
Re: encrypted sqlite using wxsqlite
« Reply #5 on: February 14, 2018, 02:13:09 pm »
hello, thank you, only encryption is needed.
As you can see on http://wiki.freepascal.org/SQLite you can use the password for the encryption key.
Quote
Use the password property to set the encryption key.

On https://github.com/utelle/wxsqlite3 you see that the command PRAGMA KEY="encryption key"; needs to be given.

If the password method doesn't work it's also possible to execute the PRAGMA command in your code itself.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus