Пример #1
0
        private string FormatUrl(object o)
        {
            SecurityClass security = new SecurityClass(encoding);

            security.FromFile(PubliCertificate);
            string notEncryText = "", encryText = "";

            System.Collections.Generic.Dictionary <string, string> dic = new Dictionary <string, string>();
            foreach (System.Reflection.PropertyInfo p in o.GetType().GetProperties())
            {
                dic.Add(p.Name, p.GetValue(o, null).ToString());
            }
            dic.OrderBy(x => x.Key).ThenBy(x => x.Value);
            foreach (KeyValuePair <string, string> kv in dic)
            {
                notEncryText += "&" + kv.Key + "=" + kv.Value;
                string txt = kv.Value;
                if (kv.Key == "batchContent")
                {
                    txt = System.Web.HttpUtility.UrlEncode(security.RSAEncrypt(txt));
                }
                encryText += "&" + kv.Key + "=" + txt;
            }
            notEncryText = notEncryText.Substring(1);
            string sign = security.MD5(notEncryText.Trim('&') + key);

            encryText = string.Format("sign={0}&signType={1}", sign, signType) + encryText;
            return(encryText);
        }
Пример #2
0
 private string FormatUrl(object o)
 {
     SecurityClass security = new SecurityClass(encoding);
     security.FromFile(PubliCertificate );
     string notEncryText="",encryText="";
     System.Collections.Generic.Dictionary<string, string> dic = new Dictionary<string, string>();
     foreach (System.Reflection.PropertyInfo p in o.GetType().GetProperties())
     {
         dic.Add(p.Name, p.GetValue(o, null).ToString());
     }
     dic.OrderBy(x => x.Key).ThenBy(x => x.Value);
     foreach (KeyValuePair<string, string> kv in dic)
     {
         notEncryText += "&" + kv.Key + "=" + kv.Value;
         string txt = kv.Value;
         if (kv.Key == "batchContent") txt = System.Web.HttpUtility.UrlEncode(security.RSAEncrypt(txt));
         encryText += "&" + kv.Key + "=" + txt;
     }
     notEncryText = notEncryText.Substring(1);
     string sign = security.MD5(notEncryText.Trim('&')+key);
     encryText = string.Format("sign={0}&signType={1}", sign, signType) + encryText;
     return encryText;
 }