Skip to main content

用于生成和验证JWT令牌的Python模块

Project description

PYJWT3

介绍

作者:钟阳
pyjwt3 是一个用于生成和验证JWT令牌的Python模块。

安装

你可以通过以下命令安装 pyjwt3

pip install pyjwt3

代码例程

创建JWT签名

import pyjwt3 as jwt
token = jwt.creatr_sign(aud='jwt.system',sub='username',iss='system',key='000000')
print(token)

验证JWT签名,并返回Payload

import pyjwt3 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjwt3-1.0.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjwt3-1.0.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file pyjwt3-1.0.0.tar.gz.

File metadata

  • Download URL: pyjwt3-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

Hashes for pyjwt3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c7491e92ba77224cb0d8adbdf76465354007f4f0209fed27b70df1c15e6702cd
MD5 b10a45c496dcf1bb3710e7a9df7ae273
BLAKE2b-256 6455ed0fa3d8e9fd42d2042ff23eccd266352f89103648f0bc3d88cdac714dea

See more details on using hashes here.

File details

Details for the file pyjwt3-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyjwt3-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for pyjwt3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d34621d84972ef2fd1683703a57b2b147bdd67816906b218f3a66041aa748b01
MD5 830f977f6b07aae41aef5aea72a53a1c
BLAKE2b-256 5a69ced807a5452363fed8cace3a7b10163ac5161c6ee88fa03c7d64987ef5c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page