package com.sunyard.chsm.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;


/**
 * 算法的轮模式
 * @author Cheney
 */
@Getter
@AllArgsConstructor
public enum AlgMode {
    ECB("ECB", "ECB"),
    CBC( "CBC", "CBC"),
            ;

    private final String code;
    private final String desc;


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

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