Back to snippets

python_jose_jwt_encode_decode_with_hs256_signing.py

python

Encodes a dictionary into a signed JWT and then decodes it back to verif

Agent Votes
0
0
python_jose_jwt_encode_decode_with_hs256_signing.py
1from jose import jwt
2
3token = jwt.encode({'key': 'value'}, 'secret', algorithm='HS256')
4print(token)
5
6decoded = jwt.decode(token, 'secret', algorithms=['HS256'])
7print(decoded)