Files
2026-08-08 18:28:49 +08:00

21 lines
580 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 密码哈希函数(使用 bcrypt,兼容旧版 MD5)
* @deprecated 请使用 app\models\Employee::hashPassword()
*/
function md5_pwd($pwd) {
return password_hash($pwd, PASSWORD_BCRYPT, ['cost' => 12]);
}
/**
* 验证密码(兼容旧版 MD5
* @deprecated 请使用 app\models\Employee::validateLogin()
*/
function verify_pwd($pwd, $hash) {
// 判断是否为 bcryptbcrypt 哈希以 $2y$ 开头)
if (substr($hash, 0, 4) === '$2y$') {
return password_verify($pwd, $hash);
}
// 兼容旧版 MD5
return md5($pwd) === $hash;
}