From 7c10d91a91e86122706699a1ee73793b5bafaa06 Mon Sep 17 00:00:00 2001 From: ChenJiaHe <763432473@qq.com> Date: 星期日, 23 一月 2022 22:41:52 +0800 Subject: [PATCH] mysql自动化加密,优化匹配查询条件 --- src/main/java/com/hx/mybatis/aes/springbean/SqlUtils.java | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hx/mybatis/aes/springbean/SqlUtils.java b/src/main/java/com/hx/mybatis/aes/springbean/SqlUtils.java index 597aa0e..b9261b6 100644 --- a/src/main/java/com/hx/mybatis/aes/springbean/SqlUtils.java +++ b/src/main/java/com/hx/mybatis/aes/springbean/SqlUtils.java @@ -138,7 +138,7 @@ }else{ tableAl = column.getName(); } - sql = sql.replaceAll("\\b"+tableAl+"\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); + sql = sql.replaceAll("\\b((?<!\\.)"+tableAl+"(?!\\.))\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); } } return sqlSelect.toString()+sql; @@ -247,7 +247,7 @@ }else{ tableAl = column.getName(); } - sql = sql.replaceAll("\\b"+tableAl+"\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); + sql = sql.replaceAll("\\b((?<!\\.)"+tableAl+"(?!\\.))\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); } } return sqlSelect.toString()+sql; @@ -411,7 +411,7 @@ }else{ tableAl = column.getName(); } - sqlWhere = sqlWhere.replaceAll("\\b"+tableAl+"\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); + sqlWhere = sqlWhere.replaceAll("\\b((?<!\\.)"+tableAl+"(?!\\.))\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); } } @@ -489,7 +489,7 @@ }else{ tableAl = column.getName(); } - sqlWhere = sqlWhere.replaceAll("\\b"+tableAl+"\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); + sqlWhere = sqlWhere.replaceAll("\\b((?<!\\.)"+tableAl+"(?!\\.))\\b","AES_DECRYPT(UNHEX("+tableAl+"),'"+aeskey+"')"); } } -- Gitblit v1.8.0