werkzeug.security.generate_password_hash(password, method='pbkdf2:sha1', salt_length=8)
method$salt$hash
>>> from werkzeug.security import generate_password_hash
>>> print generate_password_hash('123456')
'pbkdf2:sha1:1000$X97hPa3g$252c0cca000c3674b8ef7a2b8ecd409695aac370'
werkzeug.security.check_password_hash(pwhash, password)
>>> from werkzeug.security import check_password_hash >>> pwhash = 'pbkdf2:sha1:1000$X97hPa3g$252c0cca000c3674b8ef7a2b8ecd409695aac370' >>> print check_password_hash(pwhash, '123456') True
from werkzeug.security import generate_password_hash, \
check_password_hash
class User(object):
def __init__(self, username, password):
self.username = username
self.set_password(password)
def set_password(self, password):
self.pw_hash = generate_password_hash(password)
def check_password(self, password):
return check_password_hash(self.pw_hash, password)
>>> me = User('John Doe', 'default')
>>> me.pw_hash
'sha1$Z9wtkQam$7e6e814998ab3de2b63401a58063c79d92865d79'
>>> me.check_password('default')
True
>>> me.check_password('defaultx')
False
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有