public string OAuthCalculateSignature(string method, string url, Dictionary<string, string> parameters, string tokenSecret)
{
string baseString = "";
string key = ApiSecret + "&" + tokenSecret;
byte[] keyBytes = System.Text.Encoding.UTF8.GetBytes(key);
var sorted = parameters.OrderBy(p => p.Key);
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<string, string> pair in sorted)
{
if (pair.Key == "method")
{
}
else
{
sb.Append(pair.Key);
sb.Append("=");
sb.Append(UtilityMethods.EscapeOAuthString(pair.Value));
sb.Append("&");
}
}
sb.Remove(sb.Length - 1, 1);
baseString = method + "&" + UtilityMethods.EscapeOAuthString(url) + "&" + UtilityMethods.EscapeOAuthString(sb.ToString());
//System.Security.Cryptography.HMACSHA1 sha1 = new System.Security.Cryptography.HMACSHA1(keyBytes);
//byte[] hashBytes = sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(baseString));
//string hash = Convert.ToBase64String(hashBytes);
string hash = UtilityMethods.Sha1Encrypt(baseString, key);
Debug.WriteLine("key = " + key);
Debug.WriteLine("base = " + baseString);
Debug.WriteLine("sig = " + hash);
return hash;
}