private string Sign() { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("appId", appId); dic.Add("timeStamp", timestamp); dic.Add("nonceStr", nonceStr); dic.Add("package", package); dic.Add("signType", signType); Dictionary <string, string> sortDic = dic.OrderBy(e => e.Key).ToDictionary(k => k.Key, v => v.Value); StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, string> pair in sortDic) { sb.Append(pair.Key); sb.Append("="); sb.Append(pair.Value); sb.Append("&"); } sb.Append("key="); sb.Append(ConfigurationManager.AppSettings["WechatPayApiSecret"]); string sign = StringCoding.EncodeMD5(sb.ToString()).ToUpper(); LogHelper.Info(String.Format("WxPayRequest Sign :{0} -> {1}", sb.ToString(), sign)); return(sign); }
public static void Test() { string sourceString = "中国"; Console.WriteLine(StringCoding.EncodeMD5(sourceString)); Console.WriteLine(StringCoding.EncodeMD5Encrypt16(sourceString)); Console.WriteLine(StringCoding.EncodeMD5Encrypt32(sourceString)); Console.Read(); }
private void buttonMD5_Click(object sender, EventArgs e) { richTextBoxOut.Text = StringCoding.EncodeMD5(richTextBoxIn.Text); }