Tag: shopify

如何创建匹配的HMAC值以validation.NET中的Shopify WebHook?

我已经设置了一个端点来接收Shopify的webhook请求。 Shopify的请求包括从共享密钥和请求正文创建的HMAC标头。 我需要在服务器上计算HMAC并将其与请求标头中的值相匹配,以确保请求是可信的。 我似乎无法在.NET中创建适当的机制来创建匹配的HMAC值。 我的算法在这一点如下: public static string CreateHash(string data) { string sharedSecretKey = “MY_KEY”; byte[] keyBytes = Encoding.UTF8.GetBytes(sharedSecretKey); byte[] dataBytes = Encoding.UTF8.GetBytes(data); //use the SHA256Managed Class to compute the hash System.Security.Cryptography.HMACSHA256 hmac = new HMACSHA256(keyBytes); byte[] hmacBytes = hmac.ComputeHash(dataBytes); //retun as base64 string. Compared with the signature passed in the header of the post […]