using System.Security.Cryptography;
public static string HMACSHA256_Base64(string message, string secret, Encoding encoding)
byte[] keyByte = encoding.GetBytes(secret);
byte[] messageBytes = encoding.GetBytes(message);
using (var hmacsha256 = new HMACSHA256(keyByte))
byte[] hashMessage = hmacsha256.ComputeHash(messageBytes);
return Convert.ToBase64String(hashMessage);
public static void Main()
merchant_transaction_id = "21787bfdfc04bc8b0cf4b85b1537eb2",
payment_method = "xl_airtime",
item_id = "com.huoys.royalcasino.XL1",
reference_id = "ff3nugg85643"
string bodyJson = JsonConvert.SerializeObject(data);
string secret = "odF60T_HEGGX9xv";
string signature = HMACSHA256_Base64(bodyJson, secret, Encoding.UTF8);
Console.WriteLine("json: " + bodyJson);
Console.WriteLine("Generated Signature: " + signature);