Skip to content

Password

Stefano Azzolini edited this page Feb 26, 2016 · 2 revisions

The Password module allow you securely hash/verify password.

Hash a password


$hashed_passwd = Password::make('my_secret_password');
echo $hashed_passwd;
$2y$12$s88T0ByrVDPEILP2GfJUWeSqHUCFMWGFwx1XmyCguHmO2L20XuR3W

Verify password


var_dump(
  Password::verify('my_secret_password','$2y$12$s88T0ByrVDPEILP2GfJUWeSqHUCFMWGFwx1XmyCguHmO2L20XuR3W')
);
bool(true)

Compare strings in a secure way


In order to prevent a Timing Attack, you can use the compare method for comparing string equality in a time-constant way.

var_dump(
  Password::compare('my_secret_password','this-is-a-test')
);
bool(false)

Clone this wiki locally