123456789101112131415161718192021222324252627 |
- package tools
- import (
- "crypto/md5"
- "encoding/hex"
- "fmt"
- "io"
- "strings"
- )
- // Aes加密
- func MD5(sourceValue string) string {
- w := md5.New()
- io.WriteString(w, sourceValue)
- newMD5 := fmt.Sprintf("%x", w.Sum(nil))
- //return strings.ToLower(newMD5)
- return strings.ToUpper(newMD5)
- }
- //返回一个32位md5加密后的字符串
- func GetMD5Encode(data string) string {
- h := md5.New()
- h.Write([]byte(data))
- return hex.EncodeToString(h.Sum(nil))
- }
|