MySQL - How to store AES_Encrypted data?

后端 未结 4 723
天命终不由人
天命终不由人 2020-12-31 04:50

So I have been browsing the internet, and came across the MySQL built-in function AES_ENCRYPT. It doesn\'t seem too hard to use, but some sources tell me to store the encryp

相关标签:
4条回答
  • 2020-12-31 05:31

    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.

    0 讨论(0)
  • 2020-12-31 05:32

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

    0 讨论(0)
  • 2020-12-31 05:38

    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

    0 讨论(0)
  • 2020-12-31 05:44

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

    0 讨论(0)
提交回复
热议问题