Exemple #1
0
        /// <summary>
        /// 获取返回时的签名验证结果
        /// </summary>
        /// <param name="inputPara">通知返回参数数组</param>
        /// <param name="sign">对比的签名结果</param>
        /// <returns>签名验证结果</returns>
        private bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign)
        {
            //bool isSign = false;
            //if (!string.IsNullOrEmpty(sign))
            //{
            //    //获得签名结果
            //    string mysign = AliPay.BuildRequestMysign(AliPay.FilterPara(inputPara));
            //    if (mysign == sign)
            //    {
            //        isSign = true;
            //    }
            //}

            //获取待签名字符串
            string preSignStr = AliPay.CreateLinkString(AliPay.FilterPara(inputPara));

            //获得签名验证结果
            bool isSign = false;

            if (!string.IsNullOrEmpty(sign))
            {
                switch (_sign_type)
                {
                case "MD5":
                    isSign = AlipayMD5.Verify(preSignStr, sign, _key, _input_charset);
                    break;

                case "RSA":
                    isSign = RSAFromPkcs8.verify(preSignStr, sign, _public_key, _input_charset);
                    break;

                default:
                    break;
                }
            }

            return(isSign);
        }