Skip to content

Instantly share code, notes, and snippets.

@ahmdrz
Created September 1, 2016 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmdrz/ae0c222b54fc2a7c620c7084257ffe85 to your computer and use it in GitHub Desktop.
Save ahmdrz/ae0c222b54fc2a7c620c7084257ffe85 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/hmac"
"crypto/sha256"
"fmt"
)
func CheckMAC(message, messageMAC, key []byte) bool {
mac := hmac.New(sha256.New, key)
mac.Write(message)
expectedMAC := mac.Sum(nil)
return hmac.Equal(messageMAC, expectedMAC)
}
func main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment