sm3hash
English | 中文
纯 Python 实现的 SM3 哈希(GB/T 32905-2016),零依赖。
安装
pip install sm3hash
用法
from sm3hash import sm3_hex, sm3_of_file
sm3_hex("abc")
# '66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0'
sm3_hex(b"abc") # 字节原样哈希
sm3_of_file("big.iso") # 1 MiB 分块
sm3_of_file("big.iso", n_chunk=4 * 1024 * 1024)
说明
字符串先按 UTF-8 编码再哈希,要控制编码就传 bytes。大文件用 sm3_of_file 分块流式读取。纯 Python 比 hashlib.sha256 慢一个数量级——适合口令、小报文、验签,不适合追求吞吐的批量场景。
许可证
MIT
English
Pure-Python SM3 hash (GB/T 32905-2016). Zero dependencies.
Install
pip install sm3hash
Usage
from sm3hash import sm3_hex, sm3_of_file
sm3_hex("abc")
# '66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0'
sm3_hex(b"abc") # 字节原样哈希
sm3_of_file("big.iso") # 1 MiB 分块
sm3_of_file("big.iso", n_chunk=4 * 1024 * 1024)
Notes
Strings are UTF-8 encoded before hashing; pass bytes to control the encoding yourself. sm3_of_file streams large files in blocks. Pure Python is roughly an order of magnitude slower than hashlib.sha256.
License
MIT
Metadata
Release files for sm3hash 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sm3hash-0.0.3.tar.gz | 6.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sm3hash-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / sm3hash-0.0.3.tar.gz
| Download URL | sm3hash-0.0.3.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7834ad6321bd375480f46fb165e6b16c3d449dc5e5dbdfb318a0632de1db6e0
|
|
BLAKE2b-256 checksum How to use checksums |
d45004757c87b3e35ed3423ec9a5a37b5eb779ad097eace559dd7139cd36063c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / sm3hash-0.0.3-py3-none-any.whl
| Download URL | sm3hash-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2dbb0c61fb9951d286faf1f32fe04d1b979280ad35c4d85220fe7072bb3d5179
|
|
BLAKE2b-256 checksum How to use checksums |
12c7ea6d4b0a4592af6bd050deea63f7da374542cf0de52051a10d5dbdc97cce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for sm3hash 0.0.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.