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 KeyCategory {

    // 对称密钥
    SYM_KEY("sym_key", "对称密钥"),
    // 非对称密钥
    ASYM_KEY("asym_key", "非对称密钥"),
    ;

    private final String code;
    private final String desc;

    public static KeyCategory of(String code) {
        if (code == null || code.trim().isEmpty()) {
            return null;
        }

        return Arrays.stream(KeyCategory.values())
                .filter(it -> Objects.equals(it.code, code))
                .findFirst()
                .orElse(null);
    }


}
