Page 1 of 1

TLiteUtils.EncryptDatabase Examples

Posted: Sun 24 Feb 2013 09:09
by Niel
Where can I find examples on how to use TLiteUtils.EncryptDatabase method? There is no examples in the documentation.

Re: TLiteUtils.EncryptDatabase Examples

Posted: Mon 25 Feb 2013 10:41
by AlexP
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'

Re: TLiteUtils.EncryptDatabase Examples

Posted: Wed 27 Feb 2013 05:09
by Niel
Thank you Devart Support Team!