Skip to content

Instantly share code, notes, and snippets.

@scbizu
Forked from sergiotapia/md5-example.go
Last active February 7, 2017 07:47
Show Gist options
  • Save scbizu/3b351b67f759651d17cbdbe017d228b7 to your computer and use it in GitHub Desktop.
Save scbizu/3b351b67f759651d17cbdbe017d228b7 to your computer and use it in GitHub Desktop.
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
//hasher is a `io.Writer`
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment