1 添加依赖
<!-- jasypt-spring-boot-starter -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
2 加密数据项
cd C:\Users\joniu\.m2\repository\org\jasypt\jasypt\1.9.3
java -cp jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="root" password=iamsalt algorithm=PBEWithMD5AndDES
----ENVIRONMENT-----------------
Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.191-b12
----ARGUMENTS-------------------
algorithm: PBEWithMD5AndDES
input: root
password: iamsalt
----OUTPUT----------------------
gsnErpLPt3dG5SPnWkBIZw==
3 配置文件增加jasypt的配置(要放到spring部分的上面)
jasypt:
encryptor:
password: iamsalt
# 从3.0.0jasypt-spring-boot 版本开始,默认的加密/解密算法已更改为PBEWITHHMACSHA512ANDAES_256
algorithm: PBEWithMD5AndDES
iv-generator-classname: org.jasypt.iv.NoIvGenerator
4 修改配置文件中的数据项