Skip to content

Instantly share code, notes, and snippets.

@kadko
Forked from byrnedo/ComputeHmac256.go
Created March 3, 2020 04:40
Show Gist options
  • Save kadko/212f94db720a5f8760713fab086c5564 to your computer and use it in GitHub Desktop.
Save kadko/212f94db720a5f8760713fab086c5564 to your computer and use it in GitHub Desktop.
Compute a hmac for a message in golang
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment