Sqlite (vi) encryption under Delphi FIREDAC

Source: Internet
Author: User
Tags modify sqlite

The main is to set the Tfdconnection two link parameters: Password, NewPassword, very simple.

ConstDBPath = ' C:\Temp\SQLiteTest.sdb '; {The encrypted database is established, the password is mm123}procedureTform1.formcreate (Sender:tobject);Conststrtable = ' CREATE TABLE MyTable (Id integer, Name string (a), age byte) '; Id, Name, age three fieldsbegin
  ifFileExists (DBPath)thenDeleteFile (DBPath);
  FDCONNECTION1.PARAMS.ADD (' Driverid=sqlite ');
  FDCONNECTION1.PARAMS.ADD (' database= ' + dbpath); FDCONNECTION1.PARAMS.ADD (' password=mm123 '); Same with password=aes-256:mm123;  AES-256 is the default encryption algorithm; Also: aes-128,aes-192,aes-256, aes-ctr-128,aes-ctr-192,aes-ctr-256, aes-ecb-128,aes-ecb-192,aes-ecb-256/
  Build the table and enter the test data fdconnection1.execsql (strtable); Fdconnection1.execsql (' INSERT into MyTable (Id, Name, age) VALUES (: 1,: 2,: 3) ', [1, ' abc ', 23]); End; {Open a database with a password}procedureTform1.button1click (Sender:tobject);beginFDConnection1.Params.Clear;

  fdconnection1.connected: = False;
  FDCONNECTION1.PARAMS.ADD (' Driverid=sqlite ');
  FDCONNECTION1.PARAMS.ADD (' database= ' + dbpath);
  FDCONNECTION1.PARAMS.ADD (' password=mm123 ');
  fdconnection1.connected: = True; Fdquery1.open (' SELECT * from MyTable '); End; {Modify Password}procedureTform1.button2click (Sender:tobject);beginFDConnection1.Params.Clear;

  fdconnection1.connected: = False;
  FDCONNECTION1.PARAMS.ADD (' Driverid=sqlite ');
  FDCONNECTION1.PARAMS.ADD (' database= ' + dbpath);
  FDCONNECTION1.PARAMS.ADD (' password=mm123 '); FDCONNECTION1.PARAMS.ADD (' newpassword=mm12345 ');
  New password, null password for password fdconnection1.connected: = True; fdconnection1.connected: = False; End;

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Delphi/

FIREDAC also provides a dedicated cryptographic control tfdsqlitesecurity, because the above method is convenient enough, so it is not very useful.

Fdsqlitesecurity1.driverlink: = FDPhysSQLiteDriverLink1;  The other four controls in Tfdsqlitesecurity and FireDAC.Phys.SQLite specify this property before use
fdsqlitesecurity1.database: = DBPath;    Specifies the database path
fdsqlitesecurity1.password: = ' mm111 ';   Password
fdsqlitesecurity1.topassword: = ' mm222 ';//new password
Fdsqlitesecurity1.setpassword;           Set password
fdsqlitesecurity1.changepassword;        Modify password
Fdsqlitesecurity1.removepassword;        Remove password

Help says: The SQLite encrypted by FIREDAC is incompatible with it.

Author:cnblogs in case

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.