Page 1 of 1

Encrypting table field example at INSERT / UPADTE

Posted: Sun 18 Nov 2018 12:11
by ataku
Hello,

Can anyone help me with an example of how to use IBCEncryptor at INSERT / UPADTE?

I tried this way, but the data in field 'NMN' left unencrypted after commit

Code: Select all

IBQuery1.Encryption.Encryptor := IBCEncryptor1;
IBQuery1.Encryption.Fields := 'NMN';
IBCEncryptor1.Password := '12345';

IBQuery1.SQL.Text := 'INSERT INTO T_NOM_5 (NUMBE,NMN) VALUES( :NUMBE, :NMN )';
IBQuery1.ParamByName('NUMBE').AsString := '1';
IBQuery1.ParamByName('NMN').AsString := 'text123';

IBQuery1.ExecSQL;
IBTransaction1.Commit;

Thank you

DELPHI2007
FB2.1
IBDAC6.1.7

Re: Encrypting table field example at INSERT / UPADTE

Posted: Wed 21 Nov 2018 14:26
by ViktorV
In your sample you pass a value to the dataset parameter, but when using IBDAC Data Encryption you should pass a value to the dataset field. Currenlty, the parameters encryption in IBDAC Data Encryption is under development.
To change the encrypted field value in your sample, use the dataset methods Append .. Post, and as the TIBCQuery.SQL.Text SELECT value SELECT SQL query instead of INSERT. For example:

Code: Select all

IBQuery1.SQL.Text := 'SELECT NUMBE, NMN FROM T_NOM_5';
IBQuery1.Encryption.Encryptor := IBCEncryptor1;
IBQuery1.Encryption.Fields := 'NMN';
IBCEncryptor1.Password := '12345';
IBQuery1.SQL.DataTypeMap.AddFieldNameRule ('NMN', ftString);
IBQuery1.Open;
IBQuery1.Append;
IBQuery1.FieldByName('NUMBE').AsString := '1';
IBQuery1.FieldByName('NMN').AsString := 'text123';
IBQuery1.Post;