Last active
May 8, 2022 17:23
-
-
Save WGrape/625e69712cc128e4d729d8f0812012d4 to your computer and use it in GitHub Desktop.
How to use md5 in golang ?
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" | |
"encoding/hex" | |
) | |
// Md5 encode the str | |
func Md5(s string) string { | |
h := md5.New() | |
n, err := h.Write([]byte(s)) | |
if err != nil || n == 0 { | |
return "" | |
} | |
return hex.EncodeToString(h.Sum(nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment