I can encrypt with

ENCRYPT
------------
$pass = $_POST;
$query = "INSERT INTO customer(sort_code) VALUES
(AES_ENCRYPT($pass,'key'))";

the above code take a value from form and puts in the database as encrypted value.
The field type of the sort_code in my database was varchar but now i have changed to BLOB.


DECRYPT
--------

"SELECT id, aes_decrypt (sort_code,'key') FROM customer AS sort_code";
$result = mysql_query($sql);


Problem is encryption works fine , but when i use decrypt it gives me only the id but nothing for the sort_code.
I used the select statement in phpmyadmin sql and it worked fine , it gave the original input.
I need to show the original input on a page along with ids .

It should look like this ,

ID sort_code
1 433
2 4334
3 87


But all i get is
ID sort_code
1
2
3

I understand that its not outputting the value on the page, coz the select statement works fine in the sql.

I am using XAMPP ( apache 2 , PHP Version 5.2.8 , MySQL Client API version 5.1.30 )

I am stuck at this for 2 days , please good people help me !

SELECT id, aes_decrypt (sort_code,'key') AS sort_code FROM customer

Yes mate still the problem is there ! :(

Thanks mate it works now , i had some silly problem .
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.