Later, let's say you have an user-input password user_pass
. You'd hash that as well, and then compare the hash with the stored hash, and if they match, then the original passwords also matched.
Note that bcrypt automatically stores the salt value as part of the hashed password, so that you can use it when you hash the future input as well.
First time around:
import bcrypt
password = u'foobar'
salt = bcrypt.gensalt()
password_hashed = bcrypt.hashpw(password, salt)
# store 'password_hashed' in a database of your choosing
Later times:
import bcrypt
password = something_that_gets_input()
stored_hash = something_that_gets_this_from_the_db()
if bcrypt.hashpw(password, stored_hash) == stored_hash:
# password matches