Ejemplo n.º 1
0
        public virtual bool _isTenpaySign(ArrayList akeys)
        {
            StringBuilder builder = new StringBuilder();

            foreach (string str in akeys)
            {
                string strB = (string)this.parameters[str];
                if ((((strB != null) && ("".CompareTo(strB) != 0)) && ("sign".CompareTo(str) != 0)) && ("key".CompareTo(str) != 0))
                {
                    builder.Append(str + "=" + strB + "&");
                }
            }
            builder.Append("key=" + this.getKey());
            string str3 = MD5Util.GetMD5(builder.ToString(), this.getCharset()).ToLower();

            this.setDebugInfo(builder.ToString() + " => sign:" + str3);
            return(this.getParameter("sign").ToLower().Equals(str3));
        }
Ejemplo n.º 2
0
        protected virtual void createSign()
        {
            StringBuilder builder = new StringBuilder();
            ArrayList     list    = new ArrayList(this.parameters.Keys);

            list.Sort();
            foreach (string str in list)
            {
                string strB = (string)this.parameters[str];
                if ((((strB != null) && ("".CompareTo(strB) != 0)) && ("sign".CompareTo(str) != 0)) && ("key".CompareTo(str) != 0))
                {
                    builder.Append(str + "=" + strB + "&");
                }
            }
            builder.Append("key=" + this.getKey());
            string parameterValue = MD5Util.GetMD5(builder.ToString(), this.getCharset()).ToLower();

            this.setParameter("sign", parameterValue);
            this.setDebugInfo(builder.ToString() + " => sign:" + parameterValue);
        }
Ejemplo n.º 3
0
        /**
         * @Override
         * 创建签名
         */
        protected override void createSign()
        {
            //获取参数
            string cmdno            = getParameter("cmdno");
            string date             = getParameter("date");
            string bargainor_id     = getParameter("bargainor_id");
            string transaction_id   = getParameter("transaction_id");
            string sp_billno        = getParameter("sp_billno");
            string total_fee        = getParameter("total_fee");
            string fee_type         = getParameter("fee_type");
            string return_url       = getParameter("return_url");
            string attach           = getParameter("attach");
            string spbill_create_ip = getParameter("spbill_create_ip");
            string key = getParameter("key");

            //组织签名
            StringBuilder sb = new StringBuilder();

            sb.Append("cmdno=" + cmdno + "&");
            sb.Append("date=" + date + "&");
            sb.Append("bargainor_id=" + bargainor_id + "&");
            sb.Append("transaction_id=" + transaction_id + "&");
            sb.Append("sp_billno=" + sp_billno + "&");
            sb.Append("total_fee=" + total_fee + "&");
            sb.Append("fee_type=" + fee_type + "&");
            sb.Append("return_url=" + return_url + "&");
            sb.Append("attach=" + attach + "&");
            if (!"".Equals(spbill_create_ip))
            {
                sb.Append("spbill_create_ip=" + spbill_create_ip + "&");
            }
            sb.Append("key=" + getKey());

            //算出摘要
            string sign = MD5Util.GetMD5(sb.ToString(), getCharset());

            setParameter("sign", sign);

            //debug信息
            setDebugInfo(sb.ToString() + " => sign:" + sign);
        }
Ejemplo n.º 4
0
        /** 是否财付通签名,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。
         * @return boolean */
        public virtual Boolean _isTenpaySign(ArrayList akeys)
        {
            StringBuilder sb = new StringBuilder();

            foreach (string k in akeys)
            {
                string v = (string)parameters[k];
                if (null != v && "".CompareTo(v) != 0 &&
                    "sign".CompareTo(k) != 0 && "key".CompareTo(k) != 0)
                {
                    sb.Append(k + "=" + v + "&");
                }
            }

            sb.Append("key=" + this.getKey());
            string sign = MD5Util.GetMD5(sb.ToString(), getCharset()).ToLower();

            //debug信息
            this.setDebugInfo(sb.ToString() + " => sign:" + sign);
            return(getParameter("sign").ToLower().Equals(sign));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取微信签名
        /// </summary>
        /// <param name="sParams"></param>
        /// <returns></returns>
        public static string getsignext(SortedDictionary <string, string> sParams)
        {
            int           i    = 0;
            string        sign = string.Empty;
            StringBuilder sb   = new StringBuilder();

            foreach (KeyValuePair <string, string> temp in sParams)
            {
                if (temp.Value == "" || temp.Value == null || temp.Key.ToLower() == "sign")
                {
                    continue;
                }
                i++;
                sb.Append(temp.Key.Trim() + "=" + temp.Value.Trim() + "&");
            }

            string signkey = sb.ToString();

            sign = MD5Util.GetMD5(signkey, "utf-8");


            return(sign);
        }
Ejemplo n.º 6
0
        protected override void createSign()
        {
            StringBuilder builder = new StringBuilder();
            ArrayList     list    = new ArrayList();

            list.Add("spid");
            list.Add("trans_time");
            list.Add("stamp");
            list.Add("cft_signtype");
            list.Add("mchtype");
            foreach (string str in list)
            {
                string strB = (string)base.parameters[str];
                if ((((strB != null) && ("".CompareTo(strB) != 0)) && ("sign".CompareTo(str) != 0)) && ("key".CompareTo(str) != 0))
                {
                    builder.Append(str + "=" + strB + "&");
                }
            }
            builder.Append("key=" + base.getKey());
            string parameterValue = MD5Util.GetMD5(builder.ToString(), this.getCharset()).ToLower();

            base.setParameter("sign", parameterValue);
            base.setDebugInfo(builder.ToString() + " => sign:" + parameterValue);
        }
Ejemplo n.º 7
0
        /**
         * 是否财付通签名
         * @Override
         * @return boolean
         */

        public override Boolean isTenpaySign()
        {
            //获取参数
            string cmdno          = getParameter("cmdno");
            string pay_result     = getParameter("pay_result");
            string date           = getParameter("date");
            string transaction_id = getParameter("transaction_id");
            string sp_billno      = getParameter("sp_billno");
            string total_fee      = getParameter("total_fee");
            string fee_type       = getParameter("fee_type");
            string attach         = getParameter("attach");
            string tenpaySign     = getParameter("sign").ToUpper();
            string key            = this.getKey();

            //组织签名串
            StringBuilder sb = new StringBuilder();

            sb.Append("cmdno=" + cmdno + "&");
            sb.Append("pay_result=" + pay_result + "&");
            sb.Append("date=" + date + "&");
            sb.Append("transaction_id=" + transaction_id + "&");
            sb.Append("sp_billno=" + sp_billno + "&");
            sb.Append("total_fee=" + total_fee + "&");
            sb.Append("fee_type=" + fee_type + "&");
            sb.Append("attach=" + attach + "&");
            sb.Append("key=" + key);

            //算出摘要
            string sign = MD5Util.GetMD5(sb.ToString(), getCharset());

            //debug信息
            setDebugInfo(sb.ToString() + " => sign:" + sign +
                         " tenpaySign:" + tenpaySign);

            return(sign.Equals(tenpaySign));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 随机串
        /// </summary>
        public static string getNoncestr()
        {
            Random random = new Random();

            return(MD5Util.GetMD5(random.Next(1000).ToString(), "GBK").ToLower().Replace("s", "S"));
        }