feat: 更改aes密钥

This commit is contained in:
2025-06-12 16:51:48 +08:00
parent d119e7aee8
commit 31c67e8a11
2 changed files with 10 additions and 5 deletions

View File

@@ -10,20 +10,22 @@ import com.cxx.home.service.PasswordService;
import com.cxx.home.vo.PasswordQueryVo; import com.cxx.home.vo.PasswordQueryVo;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@Service @Service
public class PasswordServiceImpl implements PasswordService { public class PasswordServiceImpl implements PasswordService {
@Value("${aes.secret-key}")
private String secretKey;
@Resource @Resource
private PasswordDao passwordDao; private PasswordDao passwordDao;
@Resource @Resource
private PasswordMapper passwordMapper; private PasswordMapper passwordMapper;
private static final String SECRET_KEY = "MySuperSecretKey";
@Override @Override
public Boolean add(PasswordDto passwordDto) { public Boolean add(PasswordDto passwordDto) {
Password password = new Password(); Password password = new Password();
@@ -69,10 +71,10 @@ public class PasswordServiceImpl implements PasswordService {
} }
private String encryptPassword(String password) { 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) { private String decryptStr(String password) {
return SecureUtil.aes(SECRET_KEY.getBytes()).decryptStr(password); return SecureUtil.aes(secretKey.getBytes()).decryptStr(password);
} }
} }

View File

@@ -34,3 +34,6 @@ mybatis-plus:
web-starter: web-starter:
base-package: com.cxx.home base-package: com.cxx.home
aes:
secret-key: "sG5p7t9wBdKnPqRsUvYx2D5F8H9JmQ=2"