Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

1 Answer

Jeff Muday
Jeff Muday
Treehouse Moderator 27,497 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.