Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created November 15, 2018 07:11
Show Gist options
  • Save abhirockzz/25edadf448d64e390a1e32d8bf5e0cdf to your computer and use it in GitHub Desktop.
Save abhirockzz/25edadf448d64e390a1e32d8bf5e0cdf to your computer and use it in GitHub Desktop.
...
func matchSignature(signature, key, payload string) bool {
mac := hmac.New(sha1.New, []byte(key))
mac.Write([]byte(payload))
expectedHMAC := mac.Sum(nil)
//signature format is sha1=foobarred
githubHMAC, _ := hex.DecodeString(strings.Split(signature, "=")[1])
match := hmac.Equal(githubHMAC, expectedHMAC)
return match
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment