diff options
| author | 侯晋川 <[email protected]> | 2024-10-25 14:19:43 +0800 |
|---|---|---|
| committer | 侯晋川 <[email protected]> | 2024-10-25 14:19:43 +0800 |
| commit | 152fa429b30717cbb5964973f43c8ca0d5a22218 (patch) | |
| tree | 2719b4a0a99d03ba9cd214859af5c162eab388ba /groot-core | |
| parent | 7ab2ffecf20dd0a39c9bc63ff4f879bceb3ca704 (diff) | |
[feature][core]新增Encrypt和HMAC函数,补充提交
Diffstat (limited to 'groot-core')
| -rw-r--r-- | groot-core/src/main/java/com/geedgenetworks/core/udf/encrypt/EncryptionAlgorithm.java | 17 | ||||
| -rw-r--r-- | groot-core/src/main/java/com/geedgenetworks/core/utils/EncryptionAlgorithmUtils.java | 30 |
2 files changed, 47 insertions, 0 deletions
diff --git a/groot-core/src/main/java/com/geedgenetworks/core/udf/encrypt/EncryptionAlgorithm.java b/groot-core/src/main/java/com/geedgenetworks/core/udf/encrypt/EncryptionAlgorithm.java new file mode 100644 index 0000000..3fc4e74 --- /dev/null +++ b/groot-core/src/main/java/com/geedgenetworks/core/udf/encrypt/EncryptionAlgorithm.java @@ -0,0 +1,17 @@ +package com.geedgenetworks.core.udf.encrypt; + +import com.geedgenetworks.core.pojo.KmsKey; + +public interface EncryptionAlgorithm { + String getIdentifier(); + + int getSecretKeyLength(); + + KmsKey getKmsKey(); + + void setKmsKey(KmsKey kmsKey); + + String encrypt(String content); + + String decrypt(String content); +} diff --git a/groot-core/src/main/java/com/geedgenetworks/core/utils/EncryptionAlgorithmUtils.java b/groot-core/src/main/java/com/geedgenetworks/core/utils/EncryptionAlgorithmUtils.java new file mode 100644 index 0000000..7041c73 --- /dev/null +++ b/groot-core/src/main/java/com/geedgenetworks/core/utils/EncryptionAlgorithmUtils.java @@ -0,0 +1,30 @@ +package com.geedgenetworks.core.utils; + +import com.geedgenetworks.core.udf.encrypt.EncryptionAlgorithm; +import com.geedgenetworks.core.udf.encrypt.AES128GCM96Algorithm; +import com.geedgenetworks.core.udf.encrypt.AES256GCM96Algorithm; +import com.geedgenetworks.core.udf.encrypt.SM4GCM96Algorithm; +import lombok.extern.slf4j.Slf4j; + +/** + * Crypto shade utilities + */ +@Slf4j +public final class EncryptionAlgorithmUtils { + public static final String ALGORITHM_AES_128_GCM96_NAME = "aes-128-gcm96"; + public static final String ALGORITHM_AES_256_GCM96_NAME = "aes-256-gcm96"; + public static final String ALGORITHM_SM4_GCM96_NAME = "sm4-gcm96"; + + public static EncryptionAlgorithm getEncryptionAlgorithm(String identifier) throws Exception { + switch (identifier) { + case ALGORITHM_AES_128_GCM96_NAME: + return new AES128GCM96Algorithm(); + case ALGORITHM_AES_256_GCM96_NAME: + return new AES256GCM96Algorithm(); + case ALGORITHM_SM4_GCM96_NAME: + return new SM4GCM96Algorithm(); + default: + return null; + } + } +} |
