mybatis数据加解密

<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;
    }
}

版权声明:本文为SNOW_wu原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。