From 56744bc05cbdd2ac834be83700af180024ac9293 Mon Sep 17 00:00:00 2001 From: zyj <18107291228@163.com> Date: Fri, 12 Sep 2025 18:25:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ehash=E6=A0=B8=E5=AF=B9?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/crypto.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/crypto.go b/utils/crypto.go index e8df819..de98dd3 100644 --- a/utils/crypto.go +++ b/utils/crypto.go @@ -28,6 +28,11 @@ func (*Crypto) PasswordEncryption(password string) (string, error) { return hashedPassword, nil } +func (*Crypto) PasswordVerify(hash, password string) bool { + err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) + return err == nil +} + func (*Crypto) GenerateStateToken(tokenLength int) (string, error) { // 1. 生成密码学安全的随机字节 randomBytes := make([]byte, tokenLength)