public static string GetSign(IDictionary <string, string> pars, ApiKeyInfo apiKeyInfo) { StringBuilder sb = new StringBuilder(); foreach (var item in pars.OrderBy(x => x.Key)) { sb.Append(item.Key); sb.Append("="); sb.Append(item.Value); sb.Append("&"); } var results = sb.ToString().TrimEnd('&'); results = results + apiKeyInfo.Secret; return("&sign=" + Utils.ToMD5(results).ToLower()); }
public static string GetSign(string url, ApiKeyInfo apiKeyInfo, string par = "&sign=") { string result; string str = url.Substring(url.IndexOf("?", 4) + 1); List <string> list = str.Split('&').ToList(); list.Sort(); StringBuilder stringBuilder = new StringBuilder(); foreach (string str1 in list) { stringBuilder.Append((stringBuilder.Length > 0 ? "&" : string.Empty)); stringBuilder.Append(str1); } stringBuilder.Append(apiKeyInfo.Secret); result = Utils.ToMD5(stringBuilder.ToString()).ToLower(); return(par + result); }