PHP >= 5.5: password hashing
- Details
- Category: php
- Published: Thursday, 16 November 2017 15:52
- Written by dedet
- Hits: 219
To hash password (using default algorithm bcrypt)
$mypass = "password";
$myhash = password_hash($mypass, PASSWORD_DEFAULT);
To verify password
$brutepass = "test";
password_verify ($brutepass, $myhash); // true or false
Storing password in database
"Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters (255 characters would be a good choice)." Maybe varchar(255)