本文整理匯總了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