-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncrypt.cs
34 lines (33 loc) · 909 Bytes
/
Encrypt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
namespace AliHelper.Signature.Methods
{
public class Encrypt
{
/// <summary>
/// HMAC SHA1算法
/// </summary>
/// <param name="value"></param>
/// <param name="key"></param>
/// <returns></returns>
public static byte[] HMAC_SHA1(string value,string key)
{
try
{
byte[] keyBytes = Encoding.UTF8.GetBytes(key);
byte[] valueBytes = Encoding.UTF8.GetBytes(value);
HMACSHA1 hmac = new HMACSHA1(keyBytes);
return hmac.ComputeHash(valueBytes);
}
catch(Exception ex)
{
Console.WriteLine(ex);
throw;
}
}
}
}