だから質問はかなり^^のタイトルにある。PHP password_hash()+ password_verify()は安全です(2016年5月)?
以下は私のサーバーでパフォーマンスをテストするために行った少しのPHPコードです(結果のスクリーンショット)。また、password_hash()とpassword_verify()の使い方を示しています。
私はPASSWORD_BCRYPTと一緒に行くと思います。費用= 11あなたはどう思いますか?
<?php
$startpage = microtime(true);
$userPassword = "ILike5InchesIceCubes";
echo "<h2>Password we work on : " . $userPassword . "</h2></br></br>";
echo "<b>password_hash($userPassword, PASSWORD_BCRYPT) :</br></b>";
$start1 = microtime(true);
$hash = password_hash($userPassword, PASSWORD_BCRYPT);
echo "Hash is : " . $hash . "</br>";
echo "Encryption took : ". (microtime(true) - $start1) . " seconds </br>";
$start2 = microtime(true);
password_verify($userPassword, $hash);
echo "Password verification took : ". (microtime(true) - $start2) ." seconds </br></br>";
echo "<b>password_hash($userPassword, PASSWORD_DEFAULT) :</br></b>";
$start1 = microtime(true);
$hash = password_hash($userPassword, PASSWORD_DEFAULT);
echo "Hash is : " . $hash . "</br>";
echo "Encryption took : ". (microtime(true) - $start1) . " seconds </br>";
$start2 = microtime(true);
password_verify($userPassword, $hash);
echo "Password verification took : ". (microtime(true) - $start2) ." seconds </br></br>";
$cost = 4;
do {
echo "<b>password_hash($userPassword, PASSWORD_BCRYPT, [\"cost\" =>" . $cost . "])</br></b>";
$start1 = microtime(true);
$hash = password_hash($userPassword, PASSWORD_BCRYPT, ["cost" => $cost]);
echo "Hash is : " . $hash . "</br>";
echo "Encryption took : ". (microtime(true) - $start1) ." seconds </br>";
$start2 = microtime(true);
password_verify($userPassword, $hash);
echo "Password verification took : ". (microtime(true) - $start2) ." seconds </br></br>";
$cost++;
} while ($cost <= 16);
$endpage = microtime(true);
echo "The whole page took : ". ($endpage - $startpage) . " seconds </br>";
?>
はい。しかし、PASSWORD_DEFAULTを実行すると、サーバーのアップグレードによってハッシュアルゴリズムが同時にアップグレードされる可能性があります。これは、Bcrypt – JimL
の代わりに新しいalgoが推奨されている場合に、パスワードハッシュのセキュリティを正常にアップグレードするためにこのように実装されています。正当な値段で –
とお伝えします。あなたのことを確認してください。 1つの古典的なi7 CPU 8G RAMを使用して、実際の費用= 11実際のPASSWORD_DEFAULTを引き上げるのにどれくらい時間がかかりますか? – shrimpdrake