4,251
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// hmacSha1算法加密(生成长度40)
/// </summary>
/// <param name="encryptText">加密明文</param>
/// <param name="encryptKey">加密密钥</param>
/// <returns></returns>
public static string hmacSha1(string encryptText, string encryptKey)
{
HMACSHA1 myHMACSHA1 = new HMACSHA1(Encoding.Default.GetBytes(encryptKey));
byte[] RstRes = myHMACSHA1.ComputeHash(Encoding.Default.GetBytes(encryptText));
StringBuilder EnText = new StringBuilder();
foreach (byte Byte in RstRes)
{
EnText.AppendFormat("{0:x2}", Byte);
}
return EnText.ToString();
}