bcrypt protects user passwords by storing computationally expensive hashes instead of the original passwords. If a database leaks, the stored hash cannot simply be entered into the application as the password. section 8.3.2
Hash and verify a password
Install bcrypt with pip, then hash a password with bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode(). The random salt helps defend against rainbow-table lookups. During login, bcrypt.checkpw compares the entered password with the stored hash and returns True when they match. section 8.3.2


