MySQL - 如何存储AES_Encrypted数据? [英] MySQL - How to store AES_Encrypted data?

查看:101
本文介绍了MySQL - 如何存储AES_Encrypted数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在浏览互联网,遇到了MySQL内置函数AES_ENCRYPT。这似乎并不太难使用,但有些消息来源告诉我将加密数据存储为VARCHAR,有些则表示将其存储为BLOB。我应该将加密数据存储在哪里?

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 encrypted data as a VARCHAR, and some say to store it as a BLOB. What should I store the encrypted data as?

推荐答案


许多加密和压缩函数返回结果可能包含任意字节值。如果要存储这些结果,请使用带有VARBINARY或BLOB二进制字符串数据类型的列。这将避免后面的空格删除或字符集转换会改变数据值的潜在问题,例如,如果您使用非二进制字符串数据类型(CHAR,VARCHAR,TEXT)可能会发生。

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).

资料来源: http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html

这篇关于MySQL - 如何存储AES_Encrypted数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆