ShiErFeng/shierfeng-fastapi-backend/cli/runtime/crypto/gateway.py
2026-07-24 09:43:10 +08:00

57 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from importlib import import_module
from typing import Any
class CryptoInfrastructureGateway:
"""
传输加密基础设施网关。
该对象负责延迟加载 cryptography、环境配置和传输加密工具依赖
供传输加密运行时 facade 与其协作对象统一复用。
"""
@staticmethod
def get_serialization_module() -> Any:
"""
获取 cryptography 序列化模块。
:return: 序列化模块
"""
return import_module('cryptography.hazmat.primitives.serialization')
@staticmethod
def get_rsa_module() -> Any:
"""
获取 RSA 非对称算法模块。
:return: RSA 模块
"""
return import_module('cryptography.hazmat.primitives.asymmetric.rsa')
@staticmethod
def get_transport_crypto_config() -> Any:
"""
获取传输加密配置对象。
:return: 传输加密配置对象
"""
return import_module('config.env').TransportCryptoConfig
@staticmethod
def get_transport_crypto_util() -> Any:
"""
获取传输加密工具类。
:return: 传输加密工具类
"""
return import_module('utils.transport_crypto_util').TransportCryptoUtil
@staticmethod
def get_transport_key_provider() -> Any:
"""
获取传输加密密钥提供者。
:return: 传输加密密钥提供者
"""
return import_module('utils.transport_crypto_util').TransportKeyProvider