Metadata-Version: 2.5
Name: sm3hash
Version: 0.0.2
Summary: Pure-Python SM3 hash (GB/T 32905-2016). Zero dependencies.
Project-URL: Homepage, https://pypi.org/project/sm3hash/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: cryptography,digest,gm,hash,sm3
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# sm3hash

[English](#english) | 中文

纯 Python 实现的 SM3 哈希（GB/T 32905-2016），零依赖。

## 安装

```console
pip install sm3hash
```

## 用法

```python
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

---

<a id="english"></a>
## English

Pure-Python SM3 hash (GB/T 32905-2016). Zero dependencies.

## Install

```console
pip install sm3hash
```

## Usage

```python
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
