--创建表 uc_dict
CREATE TABLE `uc_dict` (
`type` varchar(32) NOT NULL,
`item_code` varchar(20) NOT NULL,
`item_value` blob,
`seq` int(4) DEFAULT NULL,
`note` varchar(100) DEFAULT NULL,
PRIMARY KEY (`type`,`item_code`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;
//插入
insert into uc_dict(type,item_code,item_value,seq,note)
values(#type#,#item_code#,AES_ENCRYPT(#item_value#,'icity'),#seq#,#note#)
//查询
select type,item_code,AES_DECRYPT(item_value,'icity') as item_value,seq,note from uc_dict where type=#type#
//java ibatis 查询
byte[] b = (byte[])dictDomain.getDictListByType("test").get(1).get("item_value");
System.out.println(new String(b));
类似加密函数还有encode('要加密的字符串','密钥'),decode('要解密的二进制穿','密钥')
aes_encrypt和encode加密结果都是二进制串