Encryption with UTF8 charset issue
2 Message(s) by 2 Author(s) originally posted in mysql discussion
| From: jackal_on_work |
Date: Friday, October 26, 2007
|
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
| From: Rik Wasmus |
Date: Friday, October 26, 2007
|
wrote in message:
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
string s 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
Next Message: --defaults-extra-file
Blogs related to Encryption with UTF8 charset issue
[fm-news] Newsletter for Wednesday, October 10th 2007
About: PapyrusBB is a forum that was designed specifically for use with WikyBlog. It's written in PHP with a
MySQL backend, fully integrates with the WikyBlog system using the AJAX-enhanced interface, and is
UTF-8 compatible.
...
[fm-news] Newsletter for Wednesday, October 17th 2007
language/
charset guesser for more 70 language/
charset combinations is included, along with cluster support, making it possible to distribute data over multiple computers and index huge collections with up to several
...
vBulletin Installation und Umlaute
character set connection
utf8 character set database
utf8 character set filesystem binary
character set results
utf8 character set server
utf8 character set system
utf8 character sets dir /usr/share/
mysql/charsets/
...
Ascii Characters
Creating a Table with Multiple Character Sets. Checking
Character Set Setting. Storing ASCII Characters in Non-ASCII Columns. Storing Non-ASCII Characters . On Unix, where the default is normally
UTF-8, this is a big problem,
...
MySQL Reference
(Older versions of
MySQL limited identifiers to valid alphanumeric characters from the default
character set, as well as $ and _.) This rule is limited, however, for databases and tables, because these values must be treated as files on
...
@rej I did geeklog that but i went back to change the makeconf so ...
looks fine here. yes. yet another reason for you to switch to
UTF-8. are there known problems with emerging selectwm-0.4.1? we don’t do that tehdavid. however.. do you think it is in the portage tree then? this isn’t my
issue.
...