- password_hash: documentation ( source)
- password_verify: documentation ( source)
<?php
$dangerous_pwd = 'foo' . chr(0) . 'bar';
$wrong_login_1 = 'baz';
$wrong_login_2 = 'foo';
$hash = password_hash($dangerous_pwd, PASSWORD_DEFAULT);
if (password_verify($dangerous_pwd, $hash))
echo "this is good!\n";
if (password_verify($wrong_login_1, $hash))
echo "this shouldn't happen! (1)\n";
if (password_verify($wrong_login_2, $hash))
echo "this shouldn't happen, but does! (2)\n";