using System.Security.Cryptography;
public static void Main()
const string PublicKey = "gTxGf0EVgd2mruMLHOTW";
const string PrivateKey = "ZyIpcwyP3yibjpQ1CBlW";
var MerchantTemplateKey = "First-Template";
var operatorCode = "60201";
var productCatalogName = "Courses";
var productId = "khCourse";
var RedirectUrl = "https://www.google.com";
var message = MerchantTemplateKey + msisdn + operatorCode + productId + productCatalogName + language + orderInfo + RedirectUrl;
var theDigest = CalculateDigest(PublicKey, PrivateKey, message);
Console.WriteLine(theDigest);
public static string CalculateDigest(string publicKey, string privateKey, string message)
var hash = new System.Security.Cryptography.HMACSHA256(System.Text.Encoding.UTF8.GetBytes(privateKey));
var correctHash = string.Join(string.Empty, hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(message)).Select(b => b.ToString("x2")));
digest = publicKey + ":" + correctHash;