1

私はこれに関するPHPドキュメントを読んで従いましたpassword_hash

    <?php
// first determine if a supplied password is valid
$options = ['cost' => 12,];

$hashedPassword = password_hash($plaintextPassword, PASSWORD_DEFAULT, $options);
if (password_verify($plaintextPassword, $hashedPassword)) {

    // now determine if the existing hash was created with an algorithm that is
    // no longer the default
    if (password_needs_rehash($hashedPassword, PASSWORD_DEFAULT)) {

        // create a new hash with the new default
        $newHashedPassword = password_hash($plaintextPassword, PASSWORD_DEFAULT);

        // and then save it to your data store
        //$db->update(...);
    }
}
?>

最初のハッシュがすでに有効な場合に、再度 hash_password が必要かどうかを知りたいです。

4

2 に答える 2

1

2 番目のチェックでは、パスワードが現在の PASSWORD_DEFAULT で暗号化されているかどうかを確認します。

これは、パスワード チェックというよりも、PHP の互換性/進行中のセキュリティに関するものです。

見てください: http://php.net/manual/en/function.password-hash.php

の昔md5($password)は過ぎ去りました...

于 2016-08-28T06:45:04.117 に答える