encryption - How to use AES_ENCRYPT and AES_DECRYPT in mysql -


i created user table

create  table `user` ( `id` bigint unsigned not null auto_increment , `first_name` varbinary(100) null , `address` varbinary(200) not null , primary key (`id`)) engine = innodb default character set = utf8 collate = utf8_general_ci; 

i inserted 1 row:

insert user (first_name, address) values (aes_encrypt('obama', 'usa2010'),aes_encrypt('obama', 'usa2010')); 

to select row used:

select aes_decrypt(first_name, 'usa2010'), aes_decrypt(address, 'usa2010') user; 

i getting following result.what need see data.no data visible me.

i unable see data

according manual:

aes_encrypt() encrypts string , returns binary string. aes_decrypt() decrypts encrypted string , returns original string.

i don't know why still returning binary string in case. anyway, try this:

select *,         cast(aes_decrypt(first_name, 'usa2010') char(50)) first_name_decrypt    user 

and use first_name_decrypt instead of first_name.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -