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"