· 7 years ago · Dec 25, 2018, 10:02 AM
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Security.Cryptography;
5
6namespace test1
7{
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 String encodedBody = "bbb";
13 String secretKey = "aaa";
14 using (HMACSHA1 hmac = new HMACSHA1(Encoding.UTF8.GetBytes(secretKey)))
15 {
16 byte[] c = hmac.ComputeHash(Encoding.UTF8.GetBytes(encodedBody));
17 Console.WriteLine(Convert.ToBase64String(c));
18 Console.Read();
19 }
20 }
21 }
22}