- 修复jasypt引用问题
This commit is contained in:
雨霖铃 2025-06-04 01:28:49 +08:00
parent 6384c997ad
commit acf4c56b2b
5 changed files with 18 additions and 28 deletions

View File

@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="OpenJDK17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -35,11 +35,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>
</dependency> </dependency>
<!--jasypt配置文件加解密-->
<dependency> <dependency>
<groupId>com.github.ulisesbocchio</groupId> <groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId> <artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.1</version> <version>3.0.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,15 @@
spring.mail.host=smtp.qq.com
spring.mail.port=587
spring.mail.username=2712495353@qq.com
spring.mail.password=ENC(n5TkjicC1+mKnFboGCdGTCLAhDLB6vOsN7jox7oNvy/aiJlOcX7brtnLbIRIHPiNJpY3WGAJ5DAZIgdExz4AFw==)
spring.mail.protocol=smtp
spring.mail.test-connection=false
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.ssl.enable=false
spring.mail.properties.mail.display.sendmail=spring-boot-demo
# Jasypt ??
jasypt.encryptor.password=abc

View File

@ -1,23 +0,0 @@
spring:
mail:
host: smtp.qq.com
port: 587
username: 2712495353@qq.com
# 使用 jasypt 加密密码使用com.xkcoding.email.PasswordTest.testGeneratePassword 生成加密密码,替换 ENC(加密密码)
# password: ENC(OT0qGOpXrr1Iog1W+fjOiIDCJdBjHyhy)
password: xlwpmlbawpjjdghb
protocol: smtp
test-connection: false
default-encoding: UTF-8
properties:
mail.smtp.auth: true
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.ssl.enable: false
mail.display.sendmail: spring-boot-demo
# 为 jasypt 配置解密秘钥
jasypt:
encryptor:
bean: jasyptStringEncryptor
password: spring-boot-demo
algorithm: PBEWITHHMACSHA512ANDAES_256

View File

@ -17,8 +17,7 @@ public class PasswordTest extends WorkFlowMainTests {
@Test @Test
public void testGeneratePassword() { public void testGeneratePassword() {
// 你的邮箱密码 // 你的邮箱密码
String password = "Just4Test!"; String password = "xlwpmlbawpjjdghb";
// 加密后的密码(注意配置上去的时候需要加 ENC(加密密码))
String encryptPassword = encryptor.encrypt(password); String encryptPassword = encryptor.encrypt(password);
String decryptPassword = encryptor.decrypt(encryptPassword); String decryptPassword = encryptor.decrypt(encryptPassword);