TLiteUtils.EncryptDatabase Examples

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Niel
Posts: 4
Joined: Sun 24 Feb 2013 08:54

TLiteUtils.EncryptDatabase Examples

Post by Niel » Sun 24 Feb 2013 09:09

Where can I find examples on how to use TLiteUtils.EncryptDatabase method? There is no examples in the documentation.

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

Re: TLiteUtils.EncryptDatabase Examples

Post by AlexP » Mon 25 Feb 2013 10:41

Hello,

The TLiteUtils.EncryptDatabase method allows database encryption or modifying of an existent password.

The following example shows how to encrypt an existing database:

Code: Select all

  UniConnection1.ProviderName := 'SQLite';
  UniConnection1.Database := 'C:\sqlite.db3';                                  // the name of the database to be encrypted
  UniConnection1.SpecificOptions.Values['Direct'] := 'True';
  UniConnection1.SpecificOptions.Values['EncryptionAlgorithm'] := 'laBlowfish';// the database will be encrypted with the Blowfish encryption algorithm
  UniConnection1.SpecificOptions.Values['EncryptionKey'] := '';                // no encryption key specified, because the database is not encrypted yet
  UniConnection1.Open;                                                        // connect to the database
  TLiteUtils.EncryptDatabase(UniConnection1, '11111');                      // encrypt the database using the "11111" encryption key
To change the encryption key in the encrypted database, you must perform the following:

Code: Select all

  UniConnection1.ProviderName := 'SQLite';
  UniConnection1.Database : = 'C:\sqlite_encoded.db3';                          // the name of the database to connect to
  UniConnection1.SpecificOptions.Values['Direct'] := 'True';
  UniConnection1.SpecificOptions.Values['EncryptionAlgorithm'] := 'laBlowfish'; // the encryption algorithm of the database
  UniConnection1.SpecificOptions.Values['EncryptionKey'] := '11111';            // the encryption key for the database
  UniConnection1.Open;                                       // connect to the database
  TLiteUtils.EncryptDatabase(UniConnection1, '22222');                  // change the database encryption key to '22222'

Niel
Posts: 4
Joined: Sun 24 Feb 2013 08:54

Re: TLiteUtils.EncryptDatabase Examples

Post by Niel » Wed 27 Feb 2013 05:09

Thank you Devart Support Team!

Post Reply