26 lines
465 B
Go
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))
|
|
} |