带密钥的sha1加密:

private static string HmacSha1Sign(string jsonStr, string secretKey, string enCoding )
{
  Encoding encoding = Encoding.GetEncoding(enCoding);
  string encodedParam = Convert.ToBase64String(encoding.GetBytes(jsonStr));
  byte[] bytes = encoding.GetBytes(jsonStr);
  HMACSHA1 transform = new HMACSHA1(encoding.GetBytes(secretKey));
  CryptoStream stream = new CryptoStream(Stream.Null, transform, CryptoStreamMode.Write);
  stream.Write(bytes, , bytes.Length);
  stream.Close();
  return Convert.ToBase64String(transform.Hash);
}
04-19 17:12