mysql 加密脱敏字段模糊查询
入库的数据是要进行加密脱敏的数据;但是这个字段还要支持界面模糊匹配;这里做个笔记吧
仅供参考
insert into 的sql 大概长这样
insert into tableName(id, name, idno, create_time, user_id, user_name)
values(#{id}, #{name} HEX(AES_ENCRYPT(#{idno}, #{aesKey})), #{createTime}, #{userId}, #{userName})
然后select 的sql
select id, CAST(AES_DECRYPT(UNHEX(idno), #{aesKey}) AS CHAR) idno, name, create_time createTime, user_id userId, user_name userName from tableName
where CAST(AES_DECRYPT(UNHEX(idno), #{aesKey}) AS CHAR) LIKE CONCAT('%',#{idno},'%')
参考博客
https://blog.csdn.net/weixin_43816759/article/details/120926773
https://blog.csdn.net/qq_39940205/article/details/113733233
https://blog.csdn.net/weixin_44890030/article/details/103575984
https://blog.csdn.net/qq_43632766/article/details/99295742
https://blog.csdn.net/u013614857/article/details/82858743