I have small problem with mysql. I have data in table and I want to encrypt them. I use this commands:
UPDATE `Name_Table` SET `COL1`=(SELECT AES_ENCRYPT( `COL1`, 'difficultKey')) WHERE 1
and
UPDATE `Name_Table` SET `COL1`=AES_ENCRYPT( `COL1`, 'difficultKey') WHERE 1
But this commend destroy my data (I can’t decrypt). Can you help me?
I use to this:
– phpmyadmin (bookmark – sql)
– utf8_general to comparing strings
Please, can you help me?
I feel that the data type of your column is “varchar/char”. That’s why the data is getting destroyed. Apparently you should store anything that is to be AES_ENCRYPTed in blob format
I think it is because a varchar field can’t handle certain characters that are produced from the encryption.
Quoting the MYSQL documentation for AES_ENCRYPT.
” AES_ENCRYPT() encrypts a string and returns a binary string”
Therefore, you’d need a BLOB (Binary Large object).