how to use UniEncryptor

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
densan
Posts: 4
Joined: Wed 06 Mar 2013 04:03

how to use UniEncryptor

Post by densan » Wed 06 Mar 2013 04:12

I want to encrypt to DataBase field data with unidac & postgresDB.
UniEncryptor and UniQuery paste to Form.
set up UniEncryptor.password
UniQuery.Encryption = pasted UniEncryptor

I practice to :
UniConnection1.Open;
wk_sql := 'INSERT INTO aaa (a1,a2,a3) VALUES(1,''a'',''abc'');';
with uniQuery1 do
begin
Encryption.Fields:='a3';
SQL.Clear;
SQL.Add(wk_sql);
Execute;
Close;
end;
UniConnection1.Close;

postgres aaa table a1:integer,a2:charactor varing,a3:text

But not encrypt to a3 field

hoq use UniQuery.Encryption ?

show me sample (both to insert,select)?
:cry:

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: how to use UniEncryptor

Post by AlexP » Wed 06 Mar 2013 09:25

Hello,

Encryption is not applied on DML operations (INSERT, UPDATE), in which values are set in query text. In future, we will support encryption in such queries using parameters.
Currently, to use encryption, you should work with DataSet fields, i.e:

Code: Select all

UniConnection1.Open;
with uniQuery1 do
begin
SQL.Text := 'SELECT a1,a2,a3 FROM aaa';
Encryption.Fields:='a3';
Open;
Insert;
FieldByName('a1').AsInsteger := 1;
FieldByName('a2').AsString := 'a';
FieldByName('a3').AsString := 'abc';
Post;
Close;
end;
UniConnection1.Close;

densan
Posts: 4
Joined: Wed 06 Mar 2013 04:03

Re: how to use UniEncryptor

Post by densan » Thu 07 Mar 2013 00:08

THANK YOU
It is useful because it can be encrypted in the same way as in a variety of common database :D

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: how to use UniEncryptor

Post by AlexP » Thu 07 Mar 2013 13:35

Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.

densan
Posts: 4
Joined: Wed 06 Mar 2013 04:03

Re: how to use UniEncryptor

Post by densan » Sun 17 Mar 2013 23:58

A new problem has occurred
I do not go on a field that is encrypted, so I think that where and order by
Why can not where and order by for a field that is encrypted?

example:
select a3 from aaa where a3='def' → result 0 count
select a1 from aaa order by a3 → I will not order as expected

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: how to use UniEncryptor

Post by AlexP » Mon 18 Mar 2013 10:26

Hello,
select a3 from aaa where a3='def' -> result 0 count
The WHERE condition is handled on the server, and since data is stored in a field being encrypted, this condition will always be False. To filter encrypted data, you can use a local filter, implemented by the Filter and Filtered properties.
select a1 from aaa order by a3 -> I will not order as expected
As well as the WHERE condition, the ORDER BY sorting is performed on the server side, and you will retrieve not the result you are expecting on encrypted fields. To sort such fields, you also need to use local sorting. For this, you should specify an appropriate field name in the IndexFieldNames property.

densan
Posts: 4
Joined: Wed 06 Mar 2013 04:03

Re: how to use UniEncryptor

Post by densan » Mon 18 Mar 2013 23:54

All right.
Indexednames or filters that the local side,
I would do would not be used the index of Server DB Table?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: how to use UniEncryptor

Post by AlexP » Tue 19 Mar 2013 09:49

Hello,

As I wrote earlier, when using these properties and methods, sorting and filtering are performed locally, therefore indexes created in the table are not taken into account

Post Reply