Created
November 15, 2018 07:11
-
-
Save abhirockzz/25edadf448d64e390a1e32d8bf5e0cdf to your computer and use it in GitHub Desktop.
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
... | |
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