|
|
- package wechat
-
- import (
- "crypto/md5"
- "encoding/hex"
- "strings"
- )
-
- //密码加密
- func Md5Str(str ...string) string {
-
- var build strings.Builder
- if len(str) > 0 {
- for _, v := range str {
- build.WriteString(v)
- }
- } else {
- return ""
- }
-
- h := md5.New()
- h.Write([]byte(build.String())) // 需要加密的字符串
- cipher2Str := h.Sum(nil)
- sMd5 := hex.EncodeToString(cipher2Str) // 输出加密结果
- return sMd5
- }
|