From 31c67e8a11cef74a3fdbe72522260b44e7fab2e5 Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Thu, 12 Jun 2025 16:51:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=94=B9aes=E5=AF=86=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cxx/home/service/impl/PasswordServiceImpl.java | 10 ++++++---- home-service/src/main/resources/application.yml | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/home-service/src/main/java/com/cxx/home/service/impl/PasswordServiceImpl.java b/home-service/src/main/java/com/cxx/home/service/impl/PasswordServiceImpl.java index 6da458f..4248dbb 100644 --- a/home-service/src/main/java/com/cxx/home/service/impl/PasswordServiceImpl.java +++ b/home-service/src/main/java/com/cxx/home/service/impl/PasswordServiceImpl.java @@ -10,20 +10,22 @@ import com.cxx.home.service.PasswordService; import com.cxx.home.vo.PasswordQueryVo; import jakarta.annotation.Resource; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.List; @Service public class PasswordServiceImpl implements PasswordService { + @Value("${aes.secret-key}") + private String secretKey; + @Resource private PasswordDao passwordDao; @Resource private PasswordMapper passwordMapper; - private static final String SECRET_KEY = "MySuperSecretKey"; - @Override public Boolean add(PasswordDto passwordDto) { Password password = new Password(); @@ -69,10 +71,10 @@ public class PasswordServiceImpl implements PasswordService { } private String encryptPassword(String password) { - return SecureUtil.aes(SECRET_KEY.getBytes()).encryptBase64(password); + return SecureUtil.aes(secretKey.getBytes()).encryptBase64(password); } private String decryptStr(String password) { - return SecureUtil.aes(SECRET_KEY.getBytes()).decryptStr(password); + return SecureUtil.aes(secretKey.getBytes()).decryptStr(password); } } diff --git a/home-service/src/main/resources/application.yml b/home-service/src/main/resources/application.yml index 797d506..7709d00 100644 --- a/home-service/src/main/resources/application.yml +++ b/home-service/src/main/resources/application.yml @@ -33,4 +33,7 @@ mybatis-plus: org.apache.ibatis.logging.stdout.StdOutImpl web-starter: - base-package: com.cxx.home \ No newline at end of file + base-package: com.cxx.home + +aes: + secret-key: "sG5p7t9wBdKnPqRsUvYx2D5F8H9JmQ=2"