megrez/libs/crypto/sha256.go
2024-12-29 01:02:31 +08:00

14 lines
201 B
Go

package crypto
import (
"crypto/sha256"
"encoding/hex"
)
func Sha256(str string) string {
hash := sha256.New()
hash.Write([]byte(str))
bytes := hash.Sum(nil)
return hex.EncodeToString(bytes)
}