Esempio n. 1
0
        public virtual bool isWXsign()
        {
            StringBuilder stringBuilder = new StringBuilder();
            Hashtable     hashtables    = new Hashtable();

            foreach (string key in xmlMap.Keys)
            {
                if ((key == "SignMethod" ? false : key != "AppSignature"))
                {
                    hashtables.Add(key.ToLower(), xmlMap[key]);
                }
            }
            hashtables.Add("appkey", appkey);
            ArrayList arrayLists = new ArrayList(hashtables.Keys);

            arrayLists.Sort();
            foreach (string arrayList in arrayLists)
            {
                string item = (string)hashtables[arrayList];
                if (stringBuilder.Length != 0)
                {
                    stringBuilder.Append(string.Concat("&", arrayList, "=", item));
                }
                else
                {
                    stringBuilder.Append(string.Concat(arrayList, "=", item));
                }
            }
            string lower = SHA1Util.getSha1(stringBuilder.ToString()).ToString().ToLower();

            setDebugInfo(string.Concat(stringBuilder.ToString(), " => SHA1 sign:", lower));
            return(lower.Equals(xmlMap["AppSignature"]));
        }
Esempio n. 2
0
        //判断微信签名
        public virtual Boolean isWXsign()
        {
            StringBuilder sb      = new StringBuilder();
            Hashtable     signMap = new Hashtable();

            foreach (string k in xmlMap.Keys)
            {
                if (k != "SignMethod" && k != "AppSignature")
                {
                    signMap.Add(k.ToLower(), xmlMap[k]);
                }
            }
            signMap.Add("appkey", this.appkey);

            ArrayList akeys = new ArrayList(signMap.Keys);

            akeys.Sort();

            foreach (string k in akeys)
            {
                string v = (string)signMap[k];
                if (sb.Length == 0)
                {
                    sb.Append(k + "=" + v);
                }
                else
                {
                    sb.Append("&" + k + "=" + v);
                }
            }

            string sign = SHA1Util.getSha1(sb.ToString()).ToString().ToLower();

            this.setDebugInfo(sb.ToString() + " => SHA1 sign:" + sign);

            return(sign.Equals(xmlMap["AppSignature"]));
        }