【数据库密码加密】SpringBoot集成jasypt实现数据库密码的加密

1.添加jasypt依赖包

<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>1.5-java7</version>

</dependency>

2.cmd进入包所在路径

执行如下命令:java -cp  D:\maven_repository\org\jasypt\jasypt\1.9.2\jasypt-1.9.2.jar  org.jasypt.intf.cli.JasyptPBEStringEncryptionCLIinput="123456" password=e9fbdb2d3b21 algorithm=PBEWithMD5AndDES

其中标红部分为需要加密的部分,password为加密需要的salt值,algorithm为加密算法

执行上面的命令后会出现如下内容,其中OUTPUT部分为加密后的内容

3.修改数据源配置文件

#加密使用的salt值
jasypt.encryptor.password=e9fbdb2d3b21

通过ENC进行密码解密操作

spring.datasource.password=ENC(uKPcUQufY8pCArG9T+x+SA==)

百度经验版: https://jingyan.baidu.com/album/4dc408486e54e2c8d846f146.html?picindex=6

猜你喜欢

转载自blog.csdn.net/xiaren_1988/article/details/80755787