私はこれに関する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 が必要かどうかを知りたいです。