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 trialHanwen Zhang
20,084 PointsNow 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.
#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
Treehouse Moderator 68,457 PointsHey Hanwen Zhang, the hashed string should be the password
passed in, not the literal βstringβ
Post back if you need more help. Good luck!!!
toby lacson
12,499 Pointsi don't quite understand, i need some help
Hanwen Zhang
20,084 PointsHanwen Zhang
20,084 PointsIt works now, thank you