@sales4 @sfaraclas @littlelaureates Here is C# working code
[HttpPost(Name = "events")]
public ActionResult Events(ValidateUrlEvent notification)
{
var encoding = new System.Text.ASCIIEncoding();
var sha256 = new System.Security.Cryptography.HMACSHA256();
sha256.Key = encoding.GetBytes("Your Event Secret Token");
var hash = sha256.ComputeHash(encoding.GetBytes(notification.payload.plainToken));
var hashed=ToHex(hash,false);
return Ok(
new
{
plainToken = notification.payload.plainToken,
encryptedToken = hashed
}
);
}
private static string ToHex(byte[] bytes, bool upperCase)
{
StringBuilder result = new StringBuilder(bytes.Length * 2);
for (int i = 0; i < bytes.Length; i++)
result.Append(bytes[i].ToString(upperCase ? "X2" : "x2"));
return result.ToString();
}