Skip to main content

lyzcrypto

PyPI version Python License Documentation Status

纯标准库实现的 .lyz 格式加解密库(AES-256-CBC + PKCS7 + 可选 HMAC-SHA256)。

特性

  • 零第三方依赖 — 仅使用 Python 标准库(os、hmac、hashlib、struct、json)
  • AES 纯 Python 实现 — 按 FIPS-197 标准,查表法(T-table)优化
  • Windows 自动加速 — 通过 ctypes 调用 bcrypt.dll,提速两个数量级(失败自动回退纯 Python)
  • 完整格式兼容 — 与旧实现生成的 .lyz 文件 100% 兼容

安装

pip install lyzcrypto

快速开始

字符串加解密

from lyzcrypto import LYZStringCrypto

# 初始化(密钥必须是 16/24/32 字节)
crypto = LYZStringCrypto(key=b'your-32-byte-key-here-xxxxxxxx')

# 加密
encrypted = crypto.encrypt("Hello, 世界!")
print(type(encrypted))  # <class 'bytes'>

# 解密
decrypted = crypto.decrypt(encrypted)
print(decrypted)  # Hello, 世界!

字典加解密

from lyzcrypto import LYZStringCrypto

crypto = LYZStringCrypto(key=b'your-32-byte-key-here-xxxxxxxx')

# 加密字典 → 字节流
data = {"name": "张三", "age": 25, "tags": ["python", "crypto"]}
encrypted = crypto.encrypt_dict(data)

# 解密字节流 → 字典
decrypted = crypto.decrypt_to_dict(encrypted)
print(decrypted)  # {'name': '张三', 'age': 25, 'tags': ['python', 'crypto']}

文件加解密

from lyzcrypto import LYZStringCrypto

crypto = LYZStringCrypto(key=b'your-32-byte-key-here-xxxxxxxx')

# 加密字典并写入文件
data = {"secret": "value"}
crypto.encrypt_dict_to_file(data, "secret.lyz")

# 从文件读取并解密
result = crypto.decrypt_file_to_dict("secret.lyz")

兼容明文 JSON 与加密格式

# load_json 自动识别明文 JSON 或 .lyz 加密格式
result = crypto.load_json(raw_bytes)

文件格式

| MAGIC(4B) | VERSION(1B) | IV(16B) | HMAC(32B, 可选) | ENCRYPTED_DATA |
  • MAGIC: 固定为 LYZ1
  • VERSION: 当前版本号 1
  • IV: 每次加密随机生成的 16 字节初始化向量
  • HMAC: SHA-256 校验(use_hmac=False 时省略)
  • ENCRYPTED_DATA: AES-256-CBC 加密后的数据(PKCS7 填充)

API 参考

LYZStringCrypto(key, use_hmac=True)

参数 类型 说明
key bytes 加密密钥,长度必须为 16/24/32 字节
use_hmac bool 是否启用 HMAC-SHA256 校验(默认 True)

方法

方法 说明
encrypt(data) 加密字符串或字节,返回 .lyz 格式字节流
decrypt(lyz_data) 解密 .lyz 格式数据,返回原始字符串
encrypt_dict(data_dict) 加密字典,返回 .lyz 格式字节流
decrypt_to_dict(lyz_data) 解密 .lyz 格式数据,返回字典
encrypt_dict_to_file(data_dict, file_path) 加密字典并写入文件
decrypt_file_to_dict(file_path) 从文件读取并解密为字典
load_json(raw) 自动识别明文 JSON 或 .lyz 加密格式并解析

Metadata

Release files for lyzcrypto 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lyzcrypto 0.1.0
File
lyzcrypto-0.1.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
lyzcrypto-0.1.0-cp314-cp314-manylinux_2_17_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
lyzcrypto-0.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
lyzcrypto-0.1.0-cp313-cp313-manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
lyzcrypto-0.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
lyzcrypto-0.1.0-cp312-cp312-manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
lyzcrypto-0.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
lyzcrypto-0.1.0-cp311-cp311-manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
lyzcrypto-0.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
lyzcrypto-0.1.0-cp310-cp310-manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
lyzcrypto-0.1.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
lyzcrypto-0.1.0-cp39-cp39-manylinux_2_17_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
lyzcrypto-0.1.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
lyzcrypto-0.1.0-cp38-cp38-manylinux_2_17_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details

Total release size: 7.0 MB

Release files / lyzcrypto-0.1.0-cp314-cp314-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp314-cp314-win_amd64.whl
Size 109.4 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
85ad5c7a2613494faf22aa584b9607bbbcad2686a82f5d7444125ce2a2b85858
BLAKE2b-256 checksum
How to use checksums
7d538af72fee44dd4635e27709617420818bb7694d0b22ba3b792d193bbcd582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp314-cp314-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp314-cp314-manylinux_2_17_x86_64.whl
Size 866.1 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c4191bd5ff97a9b4765b258dcb039561f029955db0fc7d4af1a7a12a45c54a18
BLAKE2b-256 checksum
How to use checksums
ce59f1539f69cfff8cca64755370435cf79fced741708fb110c3974ecc97fdbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp313-cp313-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp313-cp313-win_amd64.whl
Size 106.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
38f04431138eded4570ab813fce3140e70a4456665491fb70293d2f0a9ac9ee2
BLAKE2b-256 checksum
How to use checksums
60b3cef64a97e0063b587da4a640e273b45c7f8afed725ad60b7e0d30e874942
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp313-cp313-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp313-cp313-manylinux_2_17_x86_64.whl
Size 873.2 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6dcad694f72998ef9d6d2713a1dd0c13effc2ceba58acec0b641a4ed0c20e9a6
BLAKE2b-256 checksum
How to use checksums
df96098fc6a38bdda76ad50e80d38c320ede2acddb62506f8a12053bd53586bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp312-cp312-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp312-cp312-win_amd64.whl
Size 106.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
5ee52459ded0b925c891188f733cd76d948e241bfb3c8ab5fe18b65a5413f974
BLAKE2b-256 checksum
How to use checksums
9bc5adb293da9ec5a78296a9543be20746d6e3ba7f6e54d5e25aad0a505a7305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp312-cp312-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp312-cp312-manylinux_2_17_x86_64.whl
Size 879.3 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3c553a2537bf4b2d593b3426e6e6fba713db2b9173d4947c7fed2e8af5aa5908
BLAKE2b-256 checksum
How to use checksums
1f9e8c924f0fce51e39f3833a6e78e78577d9cda721a7bdb801665f352658d9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp311-cp311-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp311-cp311-win_amd64.whl
Size 110.7 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d9b0324ab17809d61a4e99def3d1a43cf1d4401e8308f0029cf54aa4d9999bad
BLAKE2b-256 checksum
How to use checksums
cdfb6c169e7bd1e37c57bdf4ef83b66e3ca951b30051e8980545ae81b982408c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp311-cp311-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp311-cp311-manylinux_2_17_x86_64.whl
Size 948.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a9a2f13d92de67dacbfb9c5651a66d537dfb8f20731dfbad003ab6d11584ac85
BLAKE2b-256 checksum
How to use checksums
0cae149a03a04a1522ee9398616822a209d138a5ace4bcd2e80b46fed3b7e839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp310-cp310-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp310-cp310-win_amd64.whl
Size 110.9 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
ea4845c7c271e2c3830c1915c8fea80c2d6d4d112f4b206455bf3cc6dac28396
BLAKE2b-256 checksum
How to use checksums
8750bf7d0abd485b603773c60dbb0f751cea29144d7bd25b35fe0f589bd7d7ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp310-cp310-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp310-cp310-manylinux_2_17_x86_64.whl
Size 903.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9a666a231a8cf6c5695fb094085989650e67587f8577914a3dead3872d7aa866
BLAKE2b-256 checksum
How to use checksums
31ac78f582b76c0274b1d63c3956dd22811aec8b586ac3ea45012772e8e295f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp39-cp39-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp39-cp39-win_amd64.whl
Size 111.2 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
25f67d00bb36a80865fcefddb16bc9326a17b4ab58c64f2b774ed1cbf84c1b5d
BLAKE2b-256 checksum
How to use checksums
e8a091c4ad66346e9ede87b44bd95ba0a213a4e33de7ea40578508e0c1f6ba82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp39-cp39-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp39-cp39-manylinux_2_17_x86_64.whl
Size 894.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f1132f528d8cbdd146f23537e0d0205356b80dd16903209f1ab3931b07b547c1
BLAKE2b-256 checksum
How to use checksums
2dd7afd16d2125376c5ab813b4aab60d2969020031c87fbd67aac9e678c31751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp38-cp38-win_amd64.whl

Download URL lyzcrypto-0.1.0-cp38-cp38-win_amd64.whl
Size 104.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
c7ae22ce7acee8c5580651f90a86f89dd9e61f478ab33bdff4e3e720ac40af9a
BLAKE2b-256 checksum
How to use checksums
61da36d79e58eaa8700c8e8def1a76bbb95f32e17e904ef6f9950283d9c58d16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lyzcrypto-0.1.0-cp38-cp38-manylinux_2_17_x86_64.whl

Download URL lyzcrypto-0.1.0-cp38-cp38-manylinux_2_17_x86_64.whl
Size 924.5 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6226c6d35ebeb84ec21baaca21c120571f0d8ee4afb9e20a6f387a8454c06498
BLAKE2b-256 checksum
How to use checksums
0d73a26e418c90adb4e10c1983826aebf21db5536c9af07665b2ca98b4d5aa48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Security for lyzcrypto 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 14 files in this release have been uploaded with provenance metadata.

Select from 14 files

Attestation for lyzcrypto-0.1.0-cp314-cp314-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

14 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page