Last active
March 31, 2021 18:40
Revisions
-
brainded revised this gist
Mar 31, 2021 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,15 +7,15 @@ public static class WebhookUtility public static bool IsVerified(string payload, string sharedSecret, string virtuousSignature) { byte[] valueByteArray = Encoding.UTF8.GetBytes(payload); byte[] secretByteArray = Encoding.UTF8.GetBytes(sharedSecret); using (var hmacSha256 = new HMACSHA256(secretByteArray)) { var hashedValue = hmacSha256.ComputeHash(valueByteArray); var signedPayload = Convert.ToBase64String(hashedValue); if (signedPayload.Equals(virtuousSignature)) return true; return false; } } } -
brainded created this gist
Mar 31, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ using System; using System.Text; using System.Security.Cryptography; public static class WebhookUtility { public static bool IsVerified(string payload, string sharedSecret, string virtuousSignature) { byte[] valueByteArray = Encoding.UTF8.GetBytes(payload); byte[] secretByteArray = Encoding.UTF8.GetBytes(sharedSecret); using (var hmacSha256 = new HMACSHA256(secretByteArray)) { var hashedValue = hmacSha256.ComputeHash(valueByteArray); var signedPayload = Convert.ToBase64String(hashedValue); if (signedPayload.Equals(virtuousSignature)) return true; return false; } } }