HMACSHA1加密
给有特定诉求的宝子们:/// <summary>
/// HMACSHA1加密
/// </summary>
/// <param name="text">要加密的原数据</param>
///<param name="key">私钥</param>
/// <returns></returns>
public static string HMACSHA1Text(string text, string key)
{
HMACSHA1 hmacsha1 = new HMACSHA1();
hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(key);
byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(text);
byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
return Convert.ToBase64String(hashBytes);
}
页:
[1]