对称运算类接口

This commit is contained in:
liulu
2024-12-18 09:25:41 +08:00
parent bd099ba04e
commit 9cb9b43052
39 changed files with 891 additions and 119 deletions
@@ -0,0 +1,37 @@
package com.sunyard.chsm.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Objects;
/**
* @author liulu
* @since 2024/10/22
*/
@Getter
@AllArgsConstructor
public enum KeyAlg {
SM1(KeyCategory.SYM_KEY, "SM1", "SM1"),
SM4(KeyCategory.SYM_KEY, "SM4", "SM4"),
SM2(KeyCategory.ASYM_KEY, "SM2", "SM2"),
RSA(KeyCategory.ASYM_KEY, "RSA", "RSA"),
;
private final KeyCategory category;
private final String code;
private final String desc;
public static KeyAlg of(String code) {
if (code == null || code.trim().isEmpty()) {
return null;
}
return Arrays.stream(KeyAlg.values())
.filter(it -> Objects.equals(it.code, code))
.findFirst()
.orElse(null);
}
}