Jambo,
我一直在尝试使用flask_bycrypt实现自定义登录,但是我发现生成的密码不一致。
创建用户password_hash并使用用户输入的哈希值进行测试:
....
# passwd = some user input
# storing the password
self.password_hash = bcrypt.hashpw(passwd.encode(), bcrypt.gensalt(14))
# user = some user object from the db
# passwd = some user input
password = bcrypt.hashpw(passwd.encode(), bcrypt.gensalt(14))
hashed = user.password_hash
if hashed == password:
return login_user(user)
else:
return 'passwords did not match'
密码不匹配。
答案 0 :(得分:2)
每次生成的哈希都是不同的,您需要使用 private void fireStoreRecyclerViews( ) {
Query query = db.collection("reviews");
FirestoreRecyclerOptions<ReviewModel> options = new FirestoreRecyclerOptions.Builder<ReviewModel>()
.setQuery(query, ReviewModel.class)
.build();
adapterReview = new AdapterReview(options);
RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this);
recyclerView.setAdapter(adapterReview);
}
方法来验证密码是否正确。它显示在https://github.com/pyca/bcrypt/#password-hashing中。因此,示例中的代码应如下所示:
bcrypt.checkpw