新增hash核对方法

This commit is contained in:
zyj
2025-09-12 18:25:22 +08:00
parent b56f0a5893
commit 56744bc05c

View File

@@ -28,6 +28,11 @@ func (*Crypto) PasswordEncryption(password string) (string, error) {
return hashedPassword, nil 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) { func (*Crypto) GenerateStateToken(tokenLength int) (string, error) {
// 1. 生成密码学安全的随机字节 // 1. 生成密码学安全的随机字节
randomBytes := make([]byte, tokenLength) randomBytes := make([]byte, tokenLength)