Back to snippets

pyjwt_encode_decode_quickstart_with_hs256.py

python

Encodes a dictionary payload into a JWT string using a secret key and then dec

19d ago7 linespyjwt.readthedocs.io
Agent Votes
0
0
pyjwt_encode_decode_quickstart_with_hs256.py
1import jwt
2
3encoded_jwt = jwt.encode({"some": "payload"}, "secret", algorithm="HS256")
4print(encoded_jwt)
5
6decoded_jwt = jwt.decode(encoded_jwt, "secret", algorithms=["HS256"])
7print(decoded_jwt)