Hi,
Have you tried this ? i said the length, so you can rise it until working for
tests. I used 32k and it works without any problem. I can remind that with a
blob it works also :
************************************
mysql> create table t1( asunto varbinary(32000), asun varbinary(16) );
Query OK, 0 rows affected, 1 warning (0.06 sec)

mysql> insert into t1 values(aes_encrypt('aNuevo1','asunto'), 'aNuevo1');
Query OK, 1 row affected (0.03 sec)

mysql> select aes_decrypt(asunto,'asunto') as decrypted, asun from t1;
+-----------+---------+
| decrypted | asun    |
+-----------+---------+
| aNuevo1   | aNuevo1 |
+-----------+---------+
1 row in set (0.00 sec)

********************************* But with a small length :
mysql> create table t1( asunto varbinary(16), asun varbinary(16) );
Query OK, 0 rows affected (0.08 sec)

mysql> insert into t1 values(aes_encrypt('aNuevo1','asunto'), 'aNuevo1');
Query OK, 1 row affected (0.03 sec)

mysql> select aes_decrypt(asunto,'asunto') as decrypted, asun from t1;
+-----------+---------+
| decrypted | asun    |
+-----------+---------+
| NULL      | aNuevo1 |
+-----------+---------+
1 row in set (0.00 sec)

That's why.

Hope that helps

Mathias


Selon Alejandro Alekhine <[EMAIL PROTECTED]>:

> Ok, if you´re right ... how can I repair the incorrect padding ?? Because I
> think data is correct. It fully respects so fields´ length so as
> fields´types.
>
> Thanks
>
> >From: [EMAIL PROTECTED]
> >To: Alejandro Alekhine <[EMAIL PROTECTED]>
> >CC: mysql@lists.mysql.com
> >Subject: Re: mysql decrypt
> >Date: Tue, 17 May 2005 00:30:55 +0200
> >
> >Hi,
> >You may have invalid data or incorrect padding when null is retuned :
> >
> >http://dev.mysql.com/doc/mysql/en/encryption-functions.html
> >
> >Mathias
> >
> >Selon Alejandro Alekhine <[EMAIL PROTECTED]>:
> >
> > > Hi, I´m developing a database with the aes_encrypt and aes_decrypt
> > > functions, with integrity constraints and varbinary types.
> > >
> > > My problem is that when I insert a row into a table, I encrypt with
> > > aes_encrypt, but when I desencrypt with aes_decrypt, it returns null
> >with
> > > some values. The only way I've found is using a blob type instead of
> > > varbinary, but this type doesn't support integrity constraints.
> > >
> > > For example,
> > >
> > > create table t1( asunto varbinary(16), asun varbinary(16) );
> > >
> > > insert into t1 values(aes_encrypt('aNuevo1','asunto'), 'aNuevo1');
> > >
> > > select aes_decrypt(asunto,'asunto') as decrypted, asun from t1;
> > >
> > > The result is decrypted=NULL and asun='aNuevo1'
> > >
> > > Why ??? The length of the fields is correct, I don´t know why. But if I
> > > change varbinary by blob, it runs. But with blob I can´t do any
> >integrity
> > > constraint.
> > >
> > > Thanks
> > >
> > >
> > >
> > >
> >
> >
> >
> >--
> >MySQL General Mailing List
> >For list archives: http://lists.mysql.com/mysql
> >To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> >
>
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to