public CheckValiedContent (HttpRequest request){
string xeroPrivateKey = Environment.GetEnvironmentVariable("XEROKEY");
var signatureHeader = request.Headers["x-xero-signature"];
var requestBody = request.Body;
var resultSignature = GenarateSignature(requestBody,xeroPrivateKey);
if (signatureHeader != resultSignature){
return 401
}
}
public string GenerateSignature(string dataToHash, string xeroKey)
{
using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(xeroKey)))
{
var messageBytes = Encoding.UTF8.GetBytes(dataToHash);
var hash = hmac.ComputeHash(messageBytes);
return Convert.ToBase64String(hash);
}
}