mysql数据查询,对加密字段进行模糊查询
场景:我在模糊查询电话号码的时候,发现电话号码是进行过加密的,而传进来的参数却是明文的明文参数:2352数据库是加密的:解决办法:<if test="monitorManagerListParam.phoneNumber != null and monitorManagerListParam.phoneNumber != ''">ANDAES_DECRYPT(UNHEX( cmm.PH
·
场景:我在模糊查询电话号码的时候,发现电话号码是进行过加密的,而传进来的参数却是明文的
明文参数:2352
数据库是加密的:
解决办法:
<if test="monitorManagerListParam.phoneNumber != null and monitorManagerListParam.phoneNumber != ''">
AND AES_DECRYPT(UNHEX( cmm.PHONE_NUMBER), "加密密钥") like CONCAT('%',#{monitorManagerListParam.phoneNumber},'%')
</if>
如果模糊搜索带中文,那需要如下代码:
<if test="monitorManagerListParam.keyWordThree != null and monitorManagerListParam.keyWordThree != ''">
AND CAST(binary(AES_DECRYPT(UNHEX(cmm.MESSAGE),"加密密钥"))
AS CHAR CHARACTER SET UTF8)
LIKE CONCAT('%',#{monitorManagerListParam.keyWordThree},'%')
</if>
更多推荐
已为社区贡献2条内容
所有评论(0)