python itsdangerous 签名示例

xiaoxiao2021-03-01  19

#encoding:utf8 #签名防篡改 #设置签名过期时间 #更多相关签名知识请看https://itsdangerous.readthedocs.io/en/latest/ from itsdangerous import TimestampSigner import time s = TimestampSigner('secret-key') string = s.sign('foo') # time.sleep(6) print string #尝试修改string 原文部分 替换下面string 会失败,体现防篡改功能; print s.unsign(string, max_age=5)

 

转载请注明原文地址: https://www.6miu.com/read-4049968.html

最新回复(0)