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
Post a Comment