Files
ai_wht_wechat/go_backend/utils/password.go
2026-01-06 19:36:42 +08:00

20 lines
446 B
Go
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.

package utils
import (
"crypto/sha256"
"encoding/hex"
"fmt"
)
// HashPassword 密码加密使用SHA256与Python版本保持一致
func HashPassword(password string) string {
hash := sha256.Sum256([]byte(password))
return hex.EncodeToString(hash[:])
}
// VerifyPassword 验证密码
func VerifyPassword(password, hashedPassword string) bool {
fmt.Printf(HashPassword(password))
return HashPassword(password) == hashedPassword
}