Mysql AES加解密

CREATE TABLE `test` (
  `t1` varchar(512) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
注意:字段字符集设置为latin1类型,否则插入报错字符串不正确 1366 - Incorrect string value: '\xA0\xAF7\x92\xC7\x97...' for column 't1' at row 1 
#加密 insert into test VALUES(AES_ENCRYPT('123456','key:110')) 
查询加密后得结果如下:

 

#解密 SELECT AES_DECRYPT(t1,'key:110') FROM `test`

 

 

posted @ 2023-09-05 10:33  魔力的猪  阅读(154)  评论(0编辑  收藏  举报