<!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>1.5-java7</version>
</dependency>
通過dos執行如下命令: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部分爲加密後的內容
配置文件中需要配置兩個地方:
#加密使用的salt值
jasypt.encryptor.password=e9fbdb2d3b21
通過ENC進行密碼解密操作
spring.datasource.password=ENC(uKPcUQufY8pCArG9T+x+SA==)