PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Encryption with UTF8 charset issue
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Encryption with UTF8 charset issue

Réponse
 
LinkBack Outils de la discussion
Vieux 26/10/2007, 11h23   #1
jackal_on_work@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Encryption with UTF8 charset issue

HI faculties,
I have a table tbl_users that has charset set to UTF8. The
password column in this table, should store passwords in encrypted
form. For doing this, I am using the AES_ENCRYPT() function. To my
surprise, when I tried the following statement, no data got inserted
for the password column.

These are the statements:

create table tbl_users
(
id bigint(10),
login varchar(10),
password char(10)
) default charset = utf8;

insert into tbl_users values(1, 'dan', aes_encrypt('dan', 'test'));

select * from tbl_users;

select aes_decrypt(password, 'test') from tbl_users;


The last select statement gives me a NULL value.

I have tried seeing the character set settings using the following:

show variables like '%char%'

Variable_name
Value
------------------------
-------------------------------------------------------
character_set_client
utf8
character_set_connection
utf8
character_set_database
utf8
character_set_filesystem
binary
character_set_results
utf8
character_set_server
latin1
character_set_system
utf8
character_sets_dir C:\Program Files\MySQL\MySQL Server 5.0\share
\charsets\


What can be the possible problem? Please suggest.

Thanks in advance
Jackal

  Réponse avec citation
Vieux 26/10/2007, 12h10   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Encryption with UTF8 charset issue

On Fri, 26 Oct 2007 12:23:54 +0200, <jackal_on_work@yahoo.com> wrote:

> HI faculties,
> I have a table tbl_users that has charset set to UTF8. The
> password column in this table, should store passwords in encrypted
> form. For doing this, I am using the AES_ENCRYPT() function. To my
> surprise, when I tried the following statement, no data got inserted
> for the password column.
>
> These are the statements:
>
> create table tbl_users
> (
> id bigint(10),
> login varchar(10),
> password char(10)
> ) default charset = utf8;
>
> insert into tbl_users values(1, 'dan', aes_encrypt('dan', 'test'));
>
> select * from tbl_users;
>
> select aes_decrypt(password, 'test') from tbl_users;
>
>
> The last select statement gives me a NULL value.


RTFM:
Because AES is a block-level algorithm, padding is used to encode uneven
length strings and so the result string length may be calculated using
this formula:
16 × (trunc(string_length / 16) + 1)

mysql> insert into tbl_users values(1, 'dan', aes_encrypt('dan', 'test'));
ERROR 1366 (HY000): Incorrect string value: '\xDF<\xA2\x90\xEB\x02...' for
column 'password' at row 1
mysql> select aes_encrypt('dan', 'test');
--
Rik Wasmus
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13699 seconds with 10 queries