Skip to content

Instantly share code, notes, and snippets.

@serial-coder
Forked from byrnedo/ComputeHmac256.go
Created December 20, 2020 04:17
Show Gist options
  • Save serial-coder/c5a3ad4378a6d09a5f8b75ba428983fb to your computer and use it in GitHub Desktop.
Save serial-coder/c5a3ad4378a6d09a5f8b75ba428983fb 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