/// <summary> /// HMACSHA1签名 /// </summary> /// <param name="EncryptText">签名内容</param> /// <param name="EncryptKey">密钥</param> /// <returns></returns> public static string HMACSHA1Text(string EncryptText, string EncryptKey) { HMACSHA1 hmacsha1 = new HMACSHA1(); hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey); byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText); byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer); return Convert.ToBase64String(hashBytes); }
如上,最终获取到的签名 和https://1024tools.com/hmac上面的保持一致 即正确;