Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aes_decryption don't work in phpmyadmin

I have one table in mysql database:

CREATE TABLE IF NOT EXISTS `t` (
  `q` varchar(257) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

I added two values to it - one is through mysql-console and other from phpmyadmin:

insert into t(q) values(aes_encrypt('from phpmyadmin', 123456));
insert into t(q) values(aes_encrypt('from mysql console', 123456));

And I tried to display it:

select aes_decrypt(q,123456) from t;

From mysql-console I got the following out put:

mysql> select aes_decrypt(q,123456) from t;
+-----------------------+
| aes_decrypt(q,123456) |
+-----------------------+
| from phpmyadmin       |
| from mysql console    |
+-----------------------+
2 rows in set (0.00 sec)

From phpadmin I got the following output: enter image description here

why phpmyadmin don't show correct output?

like image 957
Mohammed H Avatar asked Dec 21 '22 04:12

Mohammed H


1 Answers

aes_decrypt function produces binary data. Try

select cast(aes_decrypt(q,123456) as char) from t LIMIT 0, 30;

on your phpMyAdmin.

like image 160
Madhura Jayaratne Avatar answered Dec 31 '22 14:12

Madhura Jayaratne