MySQL - How to store AES_Encrypted data?

你离开我真会死。 提交于 2019-11-30 17:28:26

Many encryption and compression functions return strings for which the result might contain arbitrary byte values. If you want to store these results, use a column with a VARBINARY or BLOB binary string data type. This will avoid potential problems with trailing space removal or character set conversion that would change data values, such as may occur if you use a nonbinary string data type (CHAR, VARCHAR, TEXT).

Source: http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html

If you need to use VARCHAR, rather than BLOB, then convert the encrypted binary to Base64 which only uses printable characters and can be safely stored as VARCHAR. Of course you will need to convert it back from Base64 to binary before decrypting.

I have always used blobs to stored encrypted data in MySQL.

You can use Binary. BINARY in STRING. It have to work. I am using it. Write me answer if it doesn't working.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!