SpringBoot项目配置文件密码加密(jasypt)
- 引入依赖
1
2
3
4
5<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
- 找到jar文件
命令行执行:
1 | java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="hao4267364" password=abc algorithm=PBEWithMD5AndDES |
input
:是数据库的明文密码password
:是机密的盐algorithm
:是加密的方式(默认)
配置文件中使用:
1
2
3
4mail:
host: smtp.163.com
username: 18802953162@163.com # 用户名
password: ENC(0ciH5QGCy0Aww5yAcJJOfyf8iAKodNwT)用
ENC
加括号