This commit is contained in:
sjk
2026-01-06 19:36:42 +08:00
parent 15b579d64a
commit 19942144fb
261 changed files with 24034 additions and 5477 deletions

View File

@@ -0,0 +1,19 @@
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
}