使用jasypt加密解密

2021-10-01 11:51:14 字數 907 閱讀 7833

spring boot    2.1.11.release

gradle            4.8

1、在build.gradle匯入jar

implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:1.18'

jasypt.encryptor.password=yanzhi
3、使用測試類進行對字串"nihao"加密

@runwith(springjunit4classrunner.class)

public class jasypttest

}

測試結果:

4、對上面的字串進行解密

@runwith(springjunit4classrunner.class)

public class jasypttest

}

測試結果:

5、注意

jasypt多用於對配置檔案進行加密,只需要對明文的主機/賬戶/密碼進行加密,然後拿著加密後的結果寫在配置檔案,如下:

程式執行時會自動解析。

另外,對同一字串每次執行加密後的結果不一樣!!!但是只要鹽值不變,對任意加密結果解密都是乙個!!!

Java加密解密 Jasypt

1.download url 2.依賴 jar jasypt 1.9.0.jar 3.加密 預設加密 解密演算法是 pbewithmd5anddes standardpbestringencryptor encryptor new standardpbestringencryptor encrypt...

使用jasypt加密 報錯

description 只是加入jar包,啟動之後就會報錯。這個是boot版本和jasypt匹配問題。看官網可以知道目前jasypt只支援2.1.0的boot 版本。我正常使用的版本是jasypt2.1.0 對應boot 2.1.0.最近又研究了一下,因為發現有人在boot 2.2.0以上的版本用了...

jasypt 配置檔案加密

system property environment property command line argument yaml properties other custom property sources引入依賴 com.github.ulisesbocchio jasypt spring bo...