sm3hash
Pure-Python implementation of SM3, the Chinese national cryptographic hash standard (GB/T 32905-2016). No compiled extensions, no dependencies, works anywhere Python 3.10+ runs.
Produces the standard 256-bit (64 hex character) digest.
Install
pip install sm3hash
Usage
from sm3hash import sm3_hex, sm3_of_file
# text or bytes
assert sm3_hex("abc") == "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0"
# bytes are hashed as-is
sm3_hex(b"abc")
# large files, streamed in 1 MiB chunks
sm3_of_file("big.iso")
sm3_of_file("big.iso", n_chunk=4 * 1024 * 1024)
API
| Function | Description |
|---|---|
sm3_hex(data) |
Digest a str (UTF-8 encoded) or bytes, returns hex string |
sm3_of_file(path, chunk=1 MiB) |
Digest a file by streaming, returns hex string |
Strings are encoded as UTF-8 before hashing. Pass bytes to control the
encoding yourself.
Performance
Pure Python, roughly an order of magnitude slower than hashlib.sha256 on the
same input. Fine for hashing tokens, small payloads and verifying signatures;
for bulk throughput consider a C-backed SM3 binding instead.
License
MIT
Metadata
Release files for sm3hash 0.0.1
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.1.tar.gz | 6.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sm3hash-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / sm3hash-0.0.1.tar.gz
| Download URL | sm3hash-0.0.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
838c3450f3d6c3850d1ee8775c15be5dbd62ae6c0c2810493689871df786af3f
|
|
BLAKE2b-256 checksum How to use checksums |
40fd9312f683e54067c5a1121145ce3adc641a0e8cf7655b3a59e872e57c9189
|
| 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.1-py3-none-any.whl
| Download URL | sm3hash-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0cdebfc1d3c26ff1f499dadfeb600377cbb84c37932f61148e78c51b6dbcdc6
|
|
BLAKE2b-256 checksum How to use checksums |
3af3bafeaede7ca8a647719513d972944a02f674c7a7aa5c642f7950e53b4139
|
| 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.1
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.