Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python A Social Network with Flask Making Strong Users Cryptographic Hashing with Flask-Bcrypt

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,722 Points

That is a smart observation. If we simply hashed the password, you would be correct.

But the generate_password_hash() hashes the password first and then applies a "random" salt.

In some schemes, the salt is stored alongside the hash but in this case, it is randomly generated (this is the "rounds" parameter Kenneth mentions) and combined with the password. When we use check_password_hash() the function takes a password candidate and compares it to the hashed password in the database and tries a number of possible candidate salt combinations.

The combination of password hashing and salting makes dictionary (or rainbow) attacks less likely to succeed.