Page 1 of 1

TUniEncryptor Sample.

Posted: Fri 06 Jul 2012 23:58
by especialista
Is there any example regarding TUniEncryptor?
I'm not able to figure out how it works.. :oops:

Thanks in advance!

Re: TUniEncryptor Sample.

Posted: Mon 09 Jul 2012 09:06
by AlexP
hello,

Please specify your database name.

Re: TUniEncryptor Sample.

Posted: Mon 09 Jul 2012 12:05
by especialista
AlexP wrote:Please specify your database name.
Firebird, v2.5

Re: TUniEncryptor Sample.

Posted: Mon 09 Jul 2012 12:41
by AndreyZ
Table example:

Code: Select all

CREATE TABLE EMP (
  EMPNO INTEGER NOT NULL PRIMARY KEY,
  ENAME CHAR(2000) CHARACTER SET OCTETS COLLATE OCTETS,
  HIREDATE CHAR(200) CHARACTER SET OCTETS COLLATE OCTETS,
  SAL CHAR(200) CHARACTER SET OCTETS COLLATE OCTETS,
  FOTO BLOB SUB_TYPE 0
)
Code example:

Code: Select all

UniQuery.SQL.Text := 'SELECT * FROM EMP';

UniQuery.Encryption.Encryptor := UniEncryptor;
UniQuery.Encryption.Fields := 'ENAME, HIREDATE, SAL, FOTO';
UniEncryptor.Password := '11111';

UniQuery.DataTypeMap.AddFieldNameRule ('ENAME', ftString);
UniQuery.DataTypeMap.AddFieldNameRule ('HIREDATE', ftDateTime);
UniQuery.DataTypeMap.AddFieldNameRule ('SAL', ftFloat);

UniQuery.Open;
For more information, please read the "Working with Data Encryption" and "Working with Data Type Mapping" articles in the UniDAC documentation.

Re: TUniEncryptor Sample.

Posted: Mon 09 Jul 2012 14:31
by especialista
Thank you very much for your kindness!
I've tried a "copy and paste" of your code and it returns the message:

First chance exception at $7C812AFB. Exception class EUnsupportedDataTypeMapping with message 'Unsupported data type mapping: "CharBin(200)" to "DateTime"'. Process Project1.exe (3808)

Re: TUniEncryptor Sample.

Posted: Tue 10 Jul 2012 07:57
by AndreyZ
We have fixed this problem with Data Type Mapping. This fix will be included in the next UniDAC build. We are going to release UniDAC approximately in two or three weeks. For the time being, you can use the following table:

Code: Select all

CREATE TABLE EMP (
  EMPNO INTEGER NOT NULL PRIMARY KEY,
  ENAME VARCHAR(2000) CHARACTER SET OCTETS COLLATE OCTETS,
  SAL VARCHAR(200) CHARACTER SET OCTETS COLLATE OCTETS,
  FOTO BLOB SUB_TYPE 0
)
, and the following code:

Code: Select all

UniQuery.SQL.Text := 'SELECT * FROM EMP';

UniQuery.Encryption.Encryptor := UniEncryptor;
UniQuery.Encryption.Fields := 'ENAME, SAL, FOTO';
UniEncryptor.Password := '11111';

UniQuery.DataTypeMap.AddFieldNameRule ('ENAME', ftString);
UniQuery.DataTypeMap.AddFieldNameRule ('SAL', ftFloat);

UniQuery.Open;

Re: TUniEncryptor Sample.

Posted: Tue 10 Jul 2012 23:07
by especialista
AndreyZ wrote:We have fixed this problem with Data Type Mapping.
I followed your steps to the letter.
Working great with varchar fields.
SAL field retuns "Invalid binary value" error.
Let's wait for the next release.
Thanks in advance

Re: TUniEncryptor Sample.

Posted: Wed 11 Jul 2012 07:13
by AndreyZ
Please specify the following:
- the exact value you tried to set to the SAL field;
- the exact version of your IDE.

Re: TUniEncryptor Sample.

Posted: Wed 11 Jul 2012 14:58
by especialista
Image
Tried to set SAL = 0. Any value gives the same result.
Delphi XE2 Update 4 Hotfix 1.
Firebird 2.5.1

Re: TUniEncryptor Sample.

Posted: Thu 12 Jul 2012 11:58
by AndreyZ
Thank you for the information. We have reproduced and fixed this problem. This fix will be included in the next UniDAC build.

Re: TUniEncryptor Sample.

Posted: Thu 12 Jul 2012 15:24
by especialista
AndreyZ wrote:Thank you for the information. We have reproduced and fixed this problem. This fix will be included in the next UniDAC build.
My pleasure!
Thank you for promptly answers!
Best wishes!

Re: TUniEncryptor Sample.

Posted: Thu 12 Jul 2012 16:27
by AndreyZ
Feel free to contact us if you have any further questions about UniDAC.