Python 用瓶子做一个安全的密码

Python 用瓶子做一个安全的密码,python,sql,hash,passwords,salt,Python,Sql,Hash,Passwords,Salt,首先,我将Python瓶子与Sqlite一起使用。我遇到的麻烦是,当我尝试盐和散列,然后停止程序。我读过的每一页都会以其他方式生成一个密码,所以我不知道怎么做。我尝试的所有方法都是错误的 def创建(自): username=request.forms.get('username') password=request.forms.get('password') email=request.forms.get('email') sex=request.forms.get('sex') usert

首先,我将Python瓶子与Sqlite一起使用。我遇到的麻烦是,当我尝试盐和散列,然后停止程序。我读过的每一页都会以其他方式生成一个密码,所以我不知道怎么做。我尝试的所有方法都是错误的

def创建(自):
username=request.forms.get('username')
password=request.forms.get('password')
email=request.forms.get('email')
sex=request.forms.get('sex')
usertype=request.forms.get('usertype')
注册=datetime.utcnow()
salt=request.forms.get('password')salt和hash
hash=hashlib.sha512(密码+salt).hexdigest()
c=self.db.execute('在用户(用户名、电子邮件、密码、注册、性别、用户类型)中插入值(?,,,,,,,,,,)\
(哈希、salt、用户名、电子邮件、密码、注册、性别、用户类型))
使用“passlib”进行密码哈希和检查。阅读它的文档,使用它建议的一种现代算法,比如bcrypt、pbkdf2、sha512_crypt