Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Introducing the Practice2:24 with Alena Holligan
This video introduces the challenge that you'll be working to complete.
password_hash — Creates a new password hash using a strong one-way hashing algorithm.
password_verify — Verifies that the given hash matches the given password.
For Step 5 bonus, you could also setup the password hash to be part of the saveUser function. Either way, you need to make sure you're passing the correct information and actually hashing the password before saving it to the database.
Hey everyone, Alena here.
Practice is vital to becoming a proficient developer.
It solidifies what you've learned, causing it to stick in your memory.
With deliberate practice it becomes quicker and
easier to solve the challenges you'll face every day.
This session covers hashing passwords with bcrypt.
This practice session is intended to follow the Introduction
to Application Security course.
If you haven't taken that course already, make sure you jump over and
review that course.
There's a link in the Teacher's notes attached to this video,
as well as additional resources.
Step one, compare the string password with the password from the database.
I've included a database, the connection, and even grabbed the password for you.
All you need to do is compare the variable,
$dbPassword, with the string, password.
Take note that these should not match.
Step two, hash the string password with the bcrypt algorithm.
PHP includes built-in functionality for you to work with hashed passwords.
I've included links to the documentation for the functions you'll be using.
Step three, compare the hashed password with the password from the database.
Take note again that these again should not pass,
even though they are both the same password and they have both been hashed.
Step four, use the built-in function to verify the string
password matches the password from the database.
Step five, this is a bonus.
Use the saveUser function that I've included and
add a new user to the database.
Remember to always store the hashed password.
It's okay to make multiple attempts before coming to a solution.
That struggle to remember what you've learned and
apply it to the situation is what causes the knowledge to take root.
If you do get stuck,
I've included additional resources in the notes associated with this video.
Go ahead and give it a try, and I'll show you my solution in the next video.
You need to sign up for Treehouse in order to download course files.Sign up