public string sign(string key, string inputCharset) { StringBuilder stringBuilder = new StringBuilder(); this.keyValues.Sort(new KeyValues.KeyValueComparer()); foreach (KeyValue current in this.keyValues) { URLUtils.appendParam(stringBuilder, current.getKey(), current.getVal()); } URLUtils.appendParam(stringBuilder, AppConstants.KEY, key); string text = stringBuilder.ToString(); text = text.Substring(1, text.Length - 1); return(MD5Encoder.encode(text, inputCharset)); }
public static void appendParam(StringBuilder sb, string name, string val, bool and, string charset) { if (and) { sb.Append("&"); } else { sb.Append("?"); } sb.Append(name); sb.Append("="); if (val == null) { val = ""; } if (string.IsNullOrEmpty(charset)) { sb.Append(val); return; } sb.Append(URLUtils.encode(val, charset)); }
public static void appendParam(StringBuilder sb, string name, string val, bool and) { URLUtils.appendParam(sb, name, val, and, null); }
public static void appendParam(StringBuilder sb, string name, string val, string charset) { URLUtils.appendParam(sb, name, val, true, charset); }