publish zjut-1.1.3

This commit is contained in:
曾文豪
2025-12-29 17:45:59 +08:00
parent 88bc553213
commit 345d99e6a9
12 changed files with 38 additions and 28 deletions

View File

@@ -23,17 +23,26 @@ public class EncryptConfig {
/**
* 加解密对象
*/
private final SM4 sm4;
private static SM4 sm4;
/**
* 加密密钥
*/
private String key = "WmdUzPJXbngVNiaSsQrihg==";
private String key = "Z1mn6fKe6ubnm5762KR3Cg==";
private Integer saltSize = 8;
private boolean body = false;
public EncryptConfig() {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
/**
* 获取SM4对象
*
* @return
*/
private SM4 getSm4() {
if (sm4 == null) {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
}
return sm4;
}
/**
@@ -46,7 +55,7 @@ public class EncryptConfig {
if (StrUtil.isEmpty(content)) {
return "";
}
return sm4.encryptBase64(content);
return getSm4().encryptBase64(content);
}
@@ -58,7 +67,7 @@ public class EncryptConfig {
*/
public String decrypt(String base64) {
try {
return sm4.decryptStr(base64);
return getSm4().decryptStr(base64);
} catch (Exception ignore) {
}
return base64;
@@ -117,7 +126,8 @@ public class EncryptConfig {
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
public String getKey() {
return key;