Read data encryption Field

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Daniel Fagnan
Posts: 58
Joined: Fri 13 Oct 2006 00:08

Read data encryption Field

Post by Daniel Fagnan » Tue 18 Dec 2012 12:17

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

:!:

AndreyZ

Re: Read data encryption Field

Post by AndreyZ » Wed 19 Dec 2012 12:49

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;

Daniel Fagnan
Posts: 58
Joined: Fri 13 Oct 2006 00:08

Re: Read data encryption Field

Post by Daniel Fagnan » Thu 20 Dec 2012 00:20

Thank you
It's exactly then I need :lol:

AndreyZ

Re: Read data encryption Field

Post by AndreyZ » Thu 20 Dec 2012 08:00

If any other questions come up, please contact us.

Post Reply