mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
refactor(encrypt): 将 KEY_EXTRACTORS 的初始化从静态块改为 Map.of 方式
此次修改将 `KEY_EXTRACTORS` 的初始化方式从静态块改为 `Map.of`,简化了代码结构并提高了可读性。
This commit is contained in:
1 parent
1038dbefc8
commit
becbb34011
1 file changed
+11
-9
+11
-9
@@ -23,6 +23,7 @@ import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -38,15 +39,16 @@ import java.util.function.Function;
|
||||
@UtilityClass
|
||||
public class ApiCryptoUtil {
|
||||
|
||||
/**
|
||||
* 密钥提取器
|
||||
*/
|
||||
public static final Map<EncryptType, Function<ApiEncryptProperties, String>> KEY_EXTRACTORS = Map.of(
|
||||
EncryptType.AES, ApiEncryptProperties::getAesKey,
|
||||
EncryptType.RSA, ApiEncryptProperties::getRsaPrivateKey,
|
||||
EncryptType.DES, ApiEncryptProperties::getDesKey,
|
||||
EncryptType.SM4, ApiEncryptProperties::getSm4Key
|
||||
);
|
||||
public static final Map<EncryptType, Function<ApiEncryptProperties, String>> KEY_EXTRACTORS;
|
||||
|
||||
static {
|
||||
Map<EncryptType, Function<ApiEncryptProperties, String>> map = new HashMap<>();
|
||||
map.put(EncryptType.AES, ApiEncryptProperties::getAesKey);
|
||||
map.put(EncryptType.RSA, ApiEncryptProperties::getRsaPrivateKey);
|
||||
map.put(EncryptType.DES, ApiEncryptProperties::getDesKey);
|
||||
map.put(EncryptType.SM4, ApiEncryptProperties::getSm4Key);
|
||||
KEY_EXTRACTORS = map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user