You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from enum import Enum, auto
|
|
|
|
port = 8426
|
|
|
|
priKeySavePath = "./private.pem"
|
|
|
|
pubKeySavePath = "./public.pem"
|
|
|
|
|
|
|
|
class EncryptType(Enum):
|
|
|
|
AES_ECB = auto()
|
|
|
|
AES_CBC = auto()
|
|
|
|
AES_CFB = auto()
|
|
|
|
AES_OFB = auto()
|
|
|
|
SM4_ECB = auto()
|
|
|
|
SM4_CBC = auto()
|
|
|
|
|
|
|
|
# 函数:通过文本获取枚举成员
|
|
|
|
def getEncryptType(text):
|
|
|
|
try:
|
|
|
|
return EncryptType[text]
|
|
|
|
except KeyError:
|
|
|
|
raise ValueError(f"Invalid EncryptType name: {text}")
|
|
|
|
|
|
|
|
# 函数:通过枚举成员获取文本
|
|
|
|
def getEncryptTypeName(encryptType):
|
|
|
|
if not isinstance(encryptType, EncryptType):
|
|
|
|
raise TypeError("Expected a EncryptType enum member")
|
|
|
|
return encryptType.name
|