本文整理汇总了Python中itsdangerous.TimestampSigner方法的典型用法代码示例。如果您正苦于以下问题:Python itsdangerous.TimestampSigner方法的具体用法?Python itsdangerous.TimestampSigner怎么用?Python itsdangerous.TimestampSigner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类itsdangerous
的用法示例。
在下文中一共展示了itsdangerous.TimestampSigner方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: password_reset_token
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def password_reset_token(user):
signer = TimestampSigner(fame_config.secret_key)
return signer.sign(str(user['_id']))
示例2: validate_password_reset_token
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def validate_password_reset_token(token):
signer = TimestampSigner(fame_config.secret_key)
return signer.unsign(token, max_age=86400)
示例3: validate_password_reset_token
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def validate_password_reset_token(token):
signer = TimestampSigner(fame_config.secret_key)
return signer.unsign(token, max_age=86400).decode()
示例4: gen_signature
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def gen_signature(secret):
from itsdangerous import TimestampSigner
signer = TimestampSigner(secret)
return signer.sign("channelstream")
示例5: __init__
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def __init__(self):
""" Create a cypher to encrypt IDs and a signer to sign tokens."""
# Create cypher to encrypt IDs
# and ensure >=16 characters
# secret = app.config.get('SECRET_KEY')
secret = 'SECRET_KEY'
precursor = b'0123456789abcdef'
if isinstance(secret, bytes):
key = secret + precursor
else:
key = secret.encode("utf-8") + precursor
self.cipher = AES.new(key[0:16], AES.MODE_CBC)
# Create signer to sign tokens
self.signer = TimestampSigner(secret)
示例6: genCdata
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def genCdata(uid, secretkey):
s = TimestampSigner(secretkey)
cookie = s.sign(uid)
return cookie
示例7: verifyCdata
# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimestampSigner [as 别名]
def verifyCdata(cdata, secretkey, mxtime):
s = TimestampSigner(secretkey)
try:
string = s.unsign(cdata, max_age=mxtime)
return string
except:
return False