Created
March 10, 2017 12:53
-
-
Save cafeasp/aafa69976bc8e9d4769be54aa796c9d5 to your computer and use it in GitHub Desktop.
Is web hook authentic
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
public bool IsAuthenticWebhook(NameValueCollection requestHeaders, string requestBody, string shopifySecretKey) | |
{ | |
string hmacHeader = requestHeaders.Get("X-Shopify-Hmac-SHA256"); | |
if (string.IsNullOrEmpty(hmacHeader)) | |
{ | |
return false; | |
} | |
HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(shopifySecretKey)); | |
string hash = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(requestBody))); | |
return hash == hmacHeader; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment