18 lines
260 B
Go
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)
|
|
}
|