Skip to content

fireflycore/py-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

firefly-utils

firefly-utils 是 Firefly Python 的公共工具包,发布包名为 firefly-utils,导入根为 firefly.utils

首期目标是沉淀各微服务都会用到、且不携带业务语义的基础能力,优先保持小而稳定:

  • firefly.utils.compress:gzip 压缩,以及可选 zstandard 依赖存在时的 zstd 压缩。
  • firefly.utils.crypto:MD5 指纹、AES-GCM 加解密、RSA-OAEP 加解密与 RSA-PSS 签验。
  • firefly.utils.network:按 Go 版本语义拆分 host:port,缺省端口可配置。
  • firefly.utils.tlsx:三证书字段齐全才启用的 TLS 配置模型。
  • firefly.utils.slicexstructxversionfile:常用集合、结构、版本和文件辅助函数。

本地开发

uv sync
uv run pytest
uv run ruff check src tests
uv run mypy
uv build --no-sources

使用示例

from firefly.utils import aes_gcm_decrypt, aes_gcm_encrypt, split_host_port

key = b"0" * 32
ciphertext = aes_gcm_encrypt(b"hello", key)
assert aes_gcm_decrypt(ciphertext, key) == b"hello"

host_port = split_host_port("127.0.0.1", "8080")
assert host_port.host == "127.0.0.1"
assert host_port.port == "8080"

边界说明

  • 本包只放跨模块通用能力,不放微服务、Redis、ORM 等领域逻辑。
  • firefly 使用隐式 namespace package,包内不提供 src/firefly/__init__.py
  • 首个版本从 0.0.1 开始,后续公共 API 需要按兼容性策略谨慎演进。

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages