using System.Security.Cryptography;
public static byte[] HashHMAC(byte[] key, byte[] message)
var hash = new HMACSHA256(key);
return hash.ComputeHash(message);
public static string HashHMACHex(string keyHex, string message)
byte[] hash = HashHMAC(StringEncode(keyHex), StringEncode(message));
public static byte[] StringEncode(string text)
var encoding = new ASCIIEncoding();
return encoding.GetBytes(text);
public static string HashEncode(byte[] hash)
return BitConverter.ToString(hash).Replace("-", "").ToLower();