Exemple #1
0
        /// <summary>
        /// 获取待签名字符串(调试用)
        /// </summary>
        /// <returns>待签名字符串</returns>
        public string GetPreSignStr()
        {
            //过滤空值、sign与signType参数
            Dictionary <string, string> dictPara = AlipayCore.FilterPara(_paras);
            //获取待签名字符串
            string preSignStr = AlipayCore.CreateLinkString(dictPara);

            return(preSignStr);
        }
Exemple #2
0
        /// <summary>
        /// 生成请求时的签名
        /// </summary>
        /// <param name="sPara">请求给支付宝的参数数组</param>
        /// <returns>签名结果</returns>
        private static string BuildRequestMysign(Dictionary <string, string> sPara)
        {
            //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
            string prestr = AlipayCore.CreateLinkString(sPara);

            //把最终的字符串签名,获得签名结果
            string mysign = string.Empty;

            switch (SignType)
            {
            case "MD5":
                mysign = HashHelper.GetMd5(prestr + Key, Encoding.GetEncoding(InputCharset));
                break;
            }

            return(mysign);
        }
Exemple #3
0
        /// <summary>
        /// 获取返回时的签名验证结果
        /// </summary>
        /// <param name="sign">对比签名结果的方式</param>
        /// <returns>签名验证结果</returns>
        private bool GetSignVerify(string sign)
        {
            //过滤空值、sign与signType参数
            Dictionary <string, string> dictPara = AlipayCore.FilterPara(_paras);
            //获取待签名字符串
            string perSignStr = AlipayCore.CreateLinkString(dictPara);
            bool   isSign     = false;

            if (!string.IsNullOrEmpty(sign))
            {
                switch (_signType)
                {
                case "MD5":
                    isSign = Md5Verify(perSignStr, sign, _key, _inputCharset);
                    break;

                case "RSA":
                    isSign = RsaVerify(perSignStr, sign, _publicKey, _inputCharset);
                    break;
                }
            }
            return(isSign);
        }