用于生成和验证JWT令牌的Python模块
Project description
jwt-python
介绍
作者:钟阳
jwt-python 是一个用于生成和验证JWT令牌的Python模块。
安装
你可以通过以下命令安装 jwt-python:
pip install jwt-python
代码例程
创建JWT签名
import jwt-python as jwt
token = jwt.creatr_sign(aud='jwt.system',sub='username',iss='system',key='000000')
print(token)
验证JWT签名,并返回Payload
import jwt-python as jwt
#token组成:Bearer + ' ' + jwt.creatr_sign()的返回值
token = 'Bearer eyJhbGciOiAiSFMyNTYiLCAidHlwZSI6ICJKV1QifQ==.eyJhdWQiOiAiY3JtLnl1bmRhb3d1LmNuIiwgImV4cCI6IDE3NDIxNjcxNDksICJpYXQiOiAxNzQyMDgwNzQ5LCAiaXNzIjogInN5c3RlbSIsICJ1aWQiOiAxLCAic3ViIjogImFkbWluIiwgIm5iZiI6IDE3NDIwODA3NDl9.5YEtizmQHCmWBfFbhPK8bfM7binlThY_uKv--0wU_UY'
#传入的key一定要和签名时传入的key一样,并且不能泄露
payload = verify_sign(token=token, key='000000')
if payload:
print('验证通过')
print(f'Payload:{payload}')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jwt_python-1.0.0.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jwt_python-1.0.0.tar.gz.
File metadata
- Download URL: jwt_python-1.0.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a0ac0f0022199d98197d4abebc4abfa7666e285611b60e70110925e0e673131
|
|
| MD5 |
52926dd2a3266b1d1efa4c5ffdd6f2cf
|
|
| BLAKE2b-256 |
6c0c79374fcf93782d92eb68bef4d829d5457f28ca438e60573a7b04b94291f7
|
File details
Details for the file jwt_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: jwt_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5148f956f6ca629a5f9a48d2ae54a1174941f4ae228e4d3498fdab6385221875
|
|
| MD5 |
a3c6a40a81f117a74912b06d2415d6f0
|
|
| BLAKE2b-256 |
0b9da6cc1bcc46d5dcec67cc7e7da20d90bcb4a75db68ef956a747b2e496a9f9
|