using System.Security.Cryptography;
public static byte[] FromHex(string hex)
hex = hex.Replace("-", "");
byte[] raw = new byte[hex.Length / 2];
for (int i = 0; i < raw.Length; i++)
raw[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
public static void Main()
string message = @"{""requestDateTime"": ""20190613160913"",""personalId"": ""A123456789""}";
byte[] keyByte = FromHex("3050564e6b6e6539476e7974305972714e394e567177627a4548774232474a42");
var encoding = new System.Text.ASCIIEncoding();
byte[] messageBytes = encoding.GetBytes(message);
using (var hmacsha256 = new HMACSHA256(keyByte))
byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
Console.WriteLine(BitConverter.ToString(hashmessage).Replace("-", "").ToLower());