Skip to content

Instantly share code, notes, and snippets.

@JesseYan
Last active July 11, 2018 04:02
Show Gist options
  • Save JesseYan/e3b4003ca33ba93636c93515397e9f14 to your computer and use it in GitHub Desktop.
Save JesseYan/e3b4003ca33ba93636c93515397e9f14 to your computer and use it in GitHub Desktop.
md5 crypto for go version
import (
"crypto/md5"
"golang.guazi-corp.com/bi/bi_data_models/utils/log"
)
//Md5Crypto md5加密算法
func Md5Crypto(s string) string {
md5Ctx := md5.New()
_, err := md5Ctx.Write([]byte(s))
if err != nil {
log.Logger.Error("md5加密失败:", err.Error())
panic("md5加密失败")
}
cipherStr := md5Ctx.Sum(nil)
return hex.EncodeToString(cipherStr)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment