Page 1 of 1

Encrypted Sqlite connection

Posted: Fri 28 Dec 2012 11:23
by jota
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.

Re: Encrypted Sqlite connection

Posted: Fri 28 Dec 2012 13:15
by AlexP
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;