Files
ai_wht_wechat/go_backend/utils/password.go

20 lines
446 B
Go
Raw Normal View History

2026-01-06 19:36:42 +08:00
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
}