| 12345678910111213141516171819 |
- package common
- import (
- "crypto/md5"
- "fmt"
- "io"
- )
- func MD5(src string) string {
- h := md5.New()
- io.WriteString(h, src)
- return fmt.Sprintf("%x", h.Sum(nil))
- }
- func MD5ByLength16(src string) string {
- res := MD5(src)
- res = res[8:]
- res = res[:16]
- return res
- }
|