SpringBoot實現數據庫密碼的加密操作

<!-- 開啓數據庫加密 -->
<!-- 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==)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章