使用已有的加密方案加密密码

This commit is contained in:
wsczx
2024-10-28 11:53:34 +08:00
parent ff9d92a693
commit dd7d1b0e25
2 changed files with 10 additions and 60 deletions

View File

@@ -14,6 +14,10 @@ func PasswordHash(password string) (string, error) {
}
func PasswordVerify(password, hash string) bool {
// 保留老用户明文验证
if len(hash) != 60 {
return password == hash
}
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}