I have a form that I use php to retrieve data from MySQL and display that data in an input box. One of the fields is encrypted when the data is submitted into MySQL using AES_ENCRYPTED and that part works fine, I can see in the DB that that data is encrypted.
My issue is how to use AES_DECRYPT to display the decrypted data in my input box with my php code. For example my form has a field like this <input type="text" name="data" value="<?php echo $data2['data']?>"/> <--- This field being the encrypted data that I need to decrypted and display as it's original info.
I know that I can enter this at a MySQL command line SELECT aes_decrypt(dat a, '123456790abcde fghijklmnopqrst uvwxyz') FROM applications WHERE ID = '52' and it will display the data for record 52 decrypted I just don't know how to implement it in my php form.
I've tried this:
$data = "SELECT * FROM $tbl_name WHERE ID = $id";
$query = mysqli_query($c onn, $data);
$data2 = mysqli_fetch_ar ray($query);
and obviously it doesn't decrypt but it does show the encrypted data in the form.
I tried different variations of SELECT AES_DECRYPT('da ta', '$aeskey') FROM $tbl_name WHERE ID = $id"; and so on with no success.
I've tried to change the input value to value="<?php echo $data2[AES_DECRYPT('da ta', '$aeskey')]?>"/> and I get an empty input box.
Can someone help me get this solved PLEASE?
My issue is how to use AES_DECRYPT to display the decrypted data in my input box with my php code. For example my form has a field like this <input type="text" name="data" value="<?php echo $data2['data']?>"/> <--- This field being the encrypted data that I need to decrypted and display as it's original info.
I know that I can enter this at a MySQL command line SELECT aes_decrypt(dat a, '123456790abcde fghijklmnopqrst uvwxyz') FROM applications WHERE ID = '52' and it will display the data for record 52 decrypted I just don't know how to implement it in my php form.
I've tried this:
$data = "SELECT * FROM $tbl_name WHERE ID = $id";
$query = mysqli_query($c onn, $data);
$data2 = mysqli_fetch_ar ray($query);
and obviously it doesn't decrypt but it does show the encrypted data in the form.
I tried different variations of SELECT AES_DECRYPT('da ta', '$aeskey') FROM $tbl_name WHERE ID = $id"; and so on with no success.
I've tried to change the input value to value="<?php echo $data2[AES_DECRYPT('da ta', '$aeskey')]?>"/> and I get an empty input box.
Can someone help me get this solved PLEASE?
Comment