flask-bcrypt - ValueError: Invalid salt

后端 未结 11 1478
北海茫月
北海茫月 2020-12-29 07:57

I was finishing up a simple user login with Flask and flask-Bcrypt. However, when trying to login with a user that is stored in my database, I keep getting this error

<
11条回答
  •  执念已碎
    2020-12-29 08:52

    I believe you are using python 3 and bcrypt0.7.1. first you have to delete the users in your database, then go to your models and add .decode('utf-8') to the generate_password_hash() method like so:

    pw_hash = bcrypt.generate_password_hash(‘hunter2’).decode('utf-8')
    

    Alternatively you can uninstall flask-bcrypt==0.7.1 and install flask-bcrypt==0.62. Make sure you delete the users from the tables before installing flask-bcrypt==0.62

提交回复
热议问题