HMACSHA256

CSharp · Console

/Program.cs

using System;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
					
public class Program
{
	public static void Main()
	{
		Console.Write(CreateToken("cardCVC=123&cardExp=2105&cardNum=5123456789012346&holderName=John Doe&mobileNumber=20100000000000","C0DF9A7B3819968807A9D4E48D0E65C6"));
	}

	 private static string CreateToken(string message, string secret)
    {
      var encoding = new System.Text.UTF8Encoding();
      byte[] keyByte = encoding.GetBytes(secret);
      byte[] messageBytes = encoding.GetBytes(message);
      using (var hmacsha256 = new HMACSHA256(keyByte))
      {
        byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
        return BitConverter.ToString(hashmessage).Replace("-","");
      }
    }
}
;