1// To hash the password, use
2password_hash("MySuperSafePassword!", PASSWORD_DEFAULT)
3
4// To compare hash with plain text, use
5password_verify("MySuperSafePassword!", $hashed_password)
1
2<?php
3/**
4 * We just want to hash our password using the current DEFAULT algorithm.
5 * This is presently BCRYPT, and will produce a 60 character result.
6 *
7 * Beware that DEFAULT may change over time, so you would want to prepare
8 * By allowing your storage to expand past 60 characters (255 would be good)
9 */
10echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT);
11?>
12
13
1$password = 'mypassword1';
2$passwordHash = password_hash($password, PASSWORD_DEFAULT);//hash the password
3
4echo password_verify('mypassword1', $passwordHash);//true, Yeah we match
5echo password_verify('wrongpassword', $passwordHash); //false ,Ooops wrong password