Пример #1
0
        /// <summary>
        /// 获取返回时的签名验证结果
        /// </summary>
        /// <param name="inputPara">通知返回参数数组</param>
        /// <param name="sign">对比的签名结果</param>
        /// <returns>签名验证结果</returns>
        private bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign)
        {
            //过滤空值、sign与sign_type参数
            var sPara = AlipayCore.FilterPara(inputPara);

            //获取待签名字符串
            string preSignStr = AlipayCore.CreateLinkString(sPara);

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

            if (string.IsNullOrWhiteSpace(sign) == false)
            {
                switch (_config.SignType)
                {
                case "RSA":
                    isSgin = RSAFromPkcs8.Verify(preSignStr, sign, _config.PublicKey, _config.InputCharset);
                    break;

                case "MD5":
                    isSgin = VerifyByMd5(preSignStr, sign, _config.PublicKey, _config.InputCharset);
                    break;

                case "0001":
                    isSgin = RSAFromPkcs8.Verify(preSignStr, sign, _config.PublicKey, _config.InputCharset);
                    break;

                default:
                    break;
                }
            }

            return(isSgin);
        }
Пример #2
0
        /// <summary>
        /// 获取待签名字符串(调试用)
        /// </summary>
        /// <param name="inputPara">通知返回参数数组</param>
        /// <returns>待签名字符串</returns>
        private string GetPreSignStr(SortedDictionary <string, string> inputPara)
        {
            //过滤空值、sign与sign_type参数
            var sPara = AlipayCore.FilterPara(inputPara);

            //获取待签名字符串
            string preSignStr = AlipayCore.CreateLinkString(sPara);

            return(preSignStr);
        }