From 09489e74e6140859e7bbe5bd09343fbe5faf8a9a Mon Sep 17 00:00:00 2001 From: chakcy <947105045@qq.com> Date: Tue, 21 Jul 2026 16:14:47 +0800 Subject: [PATCH] =?UTF-8?q?add=20README.md=20=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bd36358 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# chongming-jwt + +基于 Rust 和 PyO3 实现的 JWT 库,性能优越,支持 HS256/HS384/HS512/RS256/RS384/RS512。 + +## 安装 + +通过 uv 自动编译(需 Rust 工具链)。 + +## 使用 + +```python +from chongming_jwt import JWT + +jwt = JWT("your-secret-key", "HS256") + +# 编码 +token = jwt.encode('{"sub": "user"}', expires_in_seconds=3600) + +# 解码 +payload = jwt.decode(token) + +# 验证 +is_valid = jwt.validate(token) +``` + +## 注意 + +- 载荷必须包含 `sub` 字段 +- 密钥建议至少 32 字节(HS256)