我希望通过对口令进行散列,然后在PSQL DB上检查散列来验证口令
我正在尝试比较散列-但我得到了一个错误的Invalid Salt.
下面是我的代码:
@app.route("/hello", methods=["POST", "GET"])
def hello():
email = request.form.get("email")
password = request.form.get("password")
password = bcrypt.generate_password_hash(password).decode('utf-8')
db.execute("INSERT INTO users (email, password) VALUES (:email,
:password)",{"email": email, "password": password})
db.commit()和
@app.route("/check", methods=["POST", "GET"])
def check():
email = request.form.get("login_email")
check_email_in_db = db.execute("SELECT COUNT(*) FROM users WHERE email = :email", {"email": email}).fetchall()
if check_email_in_db[0][0] == 1 :
email = request.form.get("login_email")
password = request.form.get("login_password")
retrive_password_from_db = db.execute("SELECT password FROM
users WHERE email = :email", {"email": email}).fetchall()
retrive_password_from_db = retrive_password_from_db[0][0]
if bcrypt.check_password_hash(password, retrive_password_from_db):
return("this works")
else:
return("something is wrong")发布于 2019-02-19 13:43:24
好了,我想通了。我所要做的就是,在散列时指定轮数:
password = bcrypt.generate_password_hash(password, 10).decode('utf-8')https://stackoverflow.com/questions/54757448
复制相似问题