独立的JWT Python库
itsdangerous
JSONWebSignatureSerializer
TimedJSONWebSignatureSerializer (可设置有效期)
pyjwt
https://pyjwt.readthedocs.io/en/latest/
安装
pip install pyjwt
实例:
import jwt
encoding_jwt = jwt.encode({'some':'payload'},'secret',algorithm='HS256')
print(encoding_jwt)
jwt_decode = jwt.decode(encoding_jwt, 'secret', algorithms=['HS256'])
print(jwt_decode)
结果:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzb21lIjoicGF5bG9hZCJ9.Joh1R2dYzkRvDkqv3sygm5YyK8Gi4ShZqbhK2gxcs2U {‘some’: ‘payload’}
在线JWT Token解析解码 https://www.cdsy.xyz/tools/jwt-decode/
JWT Token在线编码生成 https://www.cdsy.xyz/tools/jwt-encode/