PHP password hashing explained Bro Code https://www.youtube.com/watch?v=b6MpUm8CbZo Transkript (automatisch erstellt) 0:00 hello hello again everybody today I'm going to be explaining hashing in PHP hashing is the process of transforming sensitive data such as a password into 0:10 letters numbers and or symbols via a mathematical process it's kind of similar to encryption but it's technically different basically speaking 0:20 we can hide sensitive data from third parties like hackers in my example I have hashed my password pizza123 this is what my hashing 0:29 algorithm spat out it appears to be what looks like a bunch of random letters numbers and symbols we might store this in a database that in case that database 0:39 is compromised well then a third party wouldn't be able to see my original password this is what the third party would see in PHP to create a hash of 0:48 let's say a password I'll create a password variable make up some password 0:55 Pizza one two three I will create a hash variable then use the password hash function 1:06 the two arguments are a password then a hashing algorithm the second argument is technically a constant that specifies the algorithm the constant 1:18 will set is password default if we set our algorithm to be password default and PHP currently we're using the bcrypt algorithm which is a very 1:28 popular algorithm this hash is what we'll be storing within a database it's protected if I were to Echo my hash this would be the result 1:42 our password is what is referred to as plain text we can plainly see what it is using the password verify function we can compare a password versus a hash if 1:54 they're mathematically similar then that password verify function will return true let's write a if statement if 2:04 password verify then we'll pass in a password and a hash let's say that we get some user input the user types in hamburger 666. 2:17 then the other argument is going to be our hash just imagine that we're retrieving this hash from a database if our plain text 2:26 password and our hash are mathematically consistent then this function will return true so let's Echo 2:37 you are logged in else Echo incorrect password 2:50 okay is hamburger 666 the same as our hash incorrect password what about hot dog one two one two 3:00 that is also incorrect maybe pizza one two three oh look at that that's the right password you are logged in 3:09 the password verify function will verify a plain text password versus a hash if there's a match we return true if not it returns false that's really what hashing 3:20 is in layman's terms it's transforming sensitive data such as a password into letters numbers and or symbols via a mathematical process and the purpose is 3:31 to hide the original data from third parties and that is how to Hash a password in PHP