go_dreamfactory/utils/md5.go
2022-06-07 10:03:04 +08:00

18 lines
260 B
Go

package utils
import (
"crypto/md5"
"encoding/hex"
)
func MD5Str(s string) string {
return MD5Bytes([]byte(s))
}
func MD5Bytes(s []byte) string {
md5Ctx := md5.New()
md5Ctx.Write(s)
cipherStr := md5Ctx.Sum(nil)
return hex.EncodeToString(cipherStr)
}