select HEX(AES_ENCRYPT( 'test aes encrypt','123')) as aesTest
输出密文:
17CDAE577C715A0B5A922BF07462622AF15884B6D0F596B0241DC8F966C4A93F
https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt
官方文档解释:
The block_encryption_mode system variable controls the mode for block-based encryption algorithms. Its default value is <font color="red"> aes-128-ecb </font>, which signifies encryption using a key length of 128 bits and ECB mode. For a description of the permitted values of this variable, see Section 5.1.8, “Server System Variables” .
在线加密验证 : http://tool.chacuo.net/cryptaes
该网加密结果为:
17cdae577c715a0b5a922bf07462622af15884b6d0f596b0241dc8f966c4a93f
与mysql加密结果一致,只是大小写差异。
你用hibernate的话,一般情况下也会用struts2的,你可以在action里写一个MD5算法,人,在调用,如/**
* @MD5加密算法
*/
public static String digestByMD5(String str) throws Exception {
// 采用MD5加密算法,将任意长度字符串加密
MessageDigest md = MessageDigest.getInstance("MD5")
byte[] bts = md.digest(str.getBytes())
// 采用Base64算法,将加密后的字节变成字符串
BASE64Encoder encoder = new BASE64Encoder()
return encoder.encode(bts)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)