Encrypted Sqlite connection

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

Encrypted Sqlite connection

Post by jota » Fri 28 Dec 2012 11:23

Hi

I have an encrypted Sqlite database with SQLCipher.

I've been looking tuniconnection object and i don´t know where and how express 'PRAGMA key = "password"' and any other information that may be necessary to access this encrypted database.

Can anyone help me with the required code and syntax?

Thanks in advance.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Encrypted Sqlite connection

Post by AlexP » Fri 28 Dec 2012 13:15

Hello,

UniDAC supports two modes: Direct and using SQLite library. In the first mode, the encryption algorithms implemented by us (RC4, Cast128, AES256, AES192, AES128, Blowfish, TripleDES) are used, in the second mode - the algorithm embedded in the SQLite library. Since the algorithms implementation is different, a DB encrypted by different programs and libraries cannot be opened. Therefore you should encrypt your DB with UniDAC, but not SQLCipher.
There is a code below for opening an encrypted DB (there is no need to invoke PRAGMA for key installation)

Code: Select all

  UniConnection1.ProviderName := 'SQLite';
  UniConnection1.Database := 'encrypt.db3';
  //for Direct Mode
  UniConnection1.SpecificOptions.Values['Direct'] := 'True';
  UniConnection1.SpecificOptions.Values['EncryptionAlgorithm'] := 'leAES256';
  //----------------------------------
  UniConnection1.SpecificOptions.Values['EncryptionKey'] := '12345'
  UniConnection1.Connect;

Post Reply