mybatis数据加解密

2023-04-26 08:26:19
<sql id="getKey">
      '${@com.xx.xxx.xx.xx.utils.AesUtil@getKey()}'
</sql>
<sql id="Base_Column_List">
  id, name, parent_id, company_id, CONVERT(AES_DECRYPT(FROM_BASE64(phone),<include refid="getKey"/>) USING UTF8) as phone, description, delete_flag, create_by, create_time,
  modified_by, modified_time
</sql>
TO_BASE64(AES_ENCRYPT(#{phone,jdbcType=VARCHAR},<include refid="getKey"/>)),

 

@Component
@ConfigurationProperties(prefix = "aes")
public class AesUtil {
    private String key;

    private static String aesKey = "";

    public static String getKey() {
        return aesKey;
    }

    public void setKey(String key) {
        this.aesKey = key;
    }

    public static String getAesKey() {
        return aesKey;
    }

    public static void setAesKey(String aesKey) {
        AesUtil.aesKey = aesKey;
    }
}
  • 作者:Singularity_Wu
  • 原文链接:https://blog.csdn.net/SNOW_wu/article/details/90213055
    更新时间:2023-04-26 08:26:19