feat: 更改aes密钥
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,7 @@ mybatis-plus:
|
|||||||
org.apache.ibatis.logging.stdout.StdOutImpl
|
org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
web-starter:
|
web-starter:
|
||||||
base-package: com.cxx.home
|
base-package: com.cxx.home
|
||||||
|
|
||||||
|
aes:
|
||||||
|
secret-key: "sG5p7t9wBdKnPqRsUvYx2D5F8H9JmQ=2"
|
||||||
|
|||||||
Reference in New Issue
Block a user