Last active
July 11, 2018 04:02
-
-
Save JesseYan/e3b4003ca33ba93636c93515397e9f14 to your computer and use it in GitHub Desktop.
md5 crypto for go version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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