Get HMAC of a string

Get HMAC of a string

using System;

using System.Text;

using System.Security.Cryptography;

public class Program

{

public static void Main()

{

Console.WriteLine(GetHMAC("abdfasdfsdfc","fsdafasdfabc"));

}

private  static string GetHMAC(string text, string key){

using (var hmacsha256 = new HMACSHA256(Encoding.UTF8.GetBytes(key))){

var hash = hmacsha256.ComputeHash(Encoding.UTF8.GetBytes(text));

return Convert.ToBase64String(hash);

}

}

}

Comments

Popular posts from this blog

To read

Connect to Sql Database and get data C#

LINQ (Where, Min, Max, Average)