This commit is contained in:
adii1823
2021-10-28 17:39:56 +05:30
parent 48cef734e0
commit 8704175145
15 changed files with 374 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
# jwt/tok.py
import jwt
data = {'payload': 'data', 'id': 123456789}
algs = ['HS256', 'HS512']
token = jwt.encode(data, 'secret-key')
data_out = jwt.decode(token, 'secret-key', algorithms=algs)
print(token)
print(data_out)
# decode without verifying the signature
jwt.decode(token, options={'verify_signature': False})
# let's use another algorithm
token512 = jwt.encode(data, 'secret-key', algorithm='HS512')
data_out = jwt.decode(token512, 'secret-key', algorithms=['HS512'])
print(data_out)