13 lines
250 B
Go
13 lines
250 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// HashPassword 使用 SHA-256 哈希密码(与 Python 实现一致)
|
|
func HashPassword(password string) string {
|
|
h := sha256.Sum256([]byte(password))
|
|
return hex.EncodeToString(h[:])
|
|
}
|