1 2 3 4 5 6 7 8 |
public string HmacSha256(string message, string key) { var encoding = new ASCIIEncoding(); var keyByte = encoding.GetBytes(key); var sha256 = new HMACSHA256(keyByte); var messageBytes = encoding.GetBytes(message); return Convert.ToBase64String(sha256.ComputeHash(messageBytes)); } |