这个问题在这里已有答案:
我正在构建纯php web应用程序,我目前正在使用md5方法来加密用户密码我想知道在纯php应用程序中加密密码的最佳方法是什么
$hash = \password_hash($password, PASSWORD_DEFAULT);
if (\password_verify($password, $hash)) {
// Authenticated.
if (\password_needs_rehash($hash, PASSWORD_DEFAULT)) {
// Rehash, update database.
}
}