Page 1 of 1

Read data encryption Field

Posted: Tue 18 Dec 2012 12:17
by Daniel Fagnan
I tried with success Encrypt a field .
But I need to read this field and compare with a string.
How to convert encrypt value to normal value in my application.

Daniel Fagnan

:!:

Re: Read data encryption Field

Posted: Wed 19 Dec 2012 12:49
by AndreyZ
Hello,

When your application reads data from the server, IBDAC automatically decrypts it if Encryptor is specified for a dataset. Therefore, the only thing you should do, is to set the correct options of the TIBCEncryptor component, they must be the same as the ones you used when you encrypted data. Here is a code example:

Code: Select all

var
  con: TIBCConnection;
  q: TIBCQuery;
  encr: TIBCEncryptor;
begin
  con := TIBCConnection.Create(nil);
  q := TIBCQuery.Create(nil);
  encr := TIBCEncryptor.Create(nil);
  try
    ... // setting connection parameters
    q.Connection := con;
    q.Encryption.Encryptor := encr; // encr must have the correct options
    q.Encryption.Fields := 'field names'; // setting field names for which data will be decrypted
    q.Encryption.Encryptor.Password := 'password'; // the password that was used for data encryption
    q.SQL.Text := 'select * from tablename';
    q.Open; // here IBDAC decrypts data
  finally
    q.Free;
    encr.Free;
    con.Free;
  end;
end;

Re: Read data encryption Field

Posted: Thu 20 Dec 2012 00:20
by Daniel Fagnan
Thank you
It's exactly then I need :lol:

Re: Read data encryption Field

Posted: Thu 20 Dec 2012 08:00
by AndreyZ
If any other questions come up, please contact us.