hanayo/vendor/github.com/felipeweb/gopher-utils/digester.go
2019-02-23 13:29:15 +00:00

26 lines
465 B
Go

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