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 Bcryptkeeper

Now create a function named set_password that takes a user and a password that is a string. Hash the password, set the u

Now create a function named set_password that takes a user and a password that is a string. Hash the password, set the user.password attribute to the hashed password, and return the user.

password_hashing.py
#Import both generate_password_hash and check_password_hash from Flask-Bcrypt.
#Now create a function named set_password that takes a user and a password that is a string. Hash the password, set the user.password attribute to the hashed password, and return the user.

from flask.ext.bcrypt import check_password_hash, generate_password_hash

def set_password(user, password):
    user.password = generate_password_hash('string')
    return user

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,982 Points

Hey Hanwen Zhang, the hashed string should be the password passed in, not the literal ’string’

Post back if you need more help. Good luck!!!

It works now, thank you

toby lacson
toby lacson
12,361 Points

i don't quite understand, i need some help