Ejemplo n.º 1
0
        /// <summary>
        /// 获取返回时的签名验证结果
        /// </summary>
        /// <param name="inputPara">通知返回参数数组</param>
        /// <param name="sign">对比的签名结果</param>
        /// <returns>签名验证结果</returns>
        private bool GetSignVeryfy(Dictionary <string, string> inputPara, string sign)
        {
            Dictionary <string, string> sPara = new Dictionary <string, string>();

            //过滤空值、sign与sign_type参数
            sPara = AlipayCore.FilterPara(inputPara);

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

            LogHelper.SaveFileLog("SignStr", preSignStr + "&sign=" + sign);
            //获得签名验证结果
            bool isSgin = false;

            if (sign != null && sign != "")
            {
                switch (_sign_type)
                {
                case "RSA":
                    isSgin = RSAFromPkcs8.verify(preSignStr, sign, _public_key, _input_charset);
                    break;

                default:
                    break;
                }
            }

            return(isSgin);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成签名
        /// </summary>
        /// <param name="dicArray"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string CreateSign(Dictionary <string, string> dicArray)
        {
            //过滤空值、sign与sign_type参数
            Dictionary <string, string> dicSign = FilterPara(dicArray);
            //获取待签名字符串
            string strSign = AlipayCore.CreateLinkString(dicSign);

            //生成签名
            return(RSAFromPkcs8.sign(strSign, AlipayConfig.Private_key, AlipayConfig.Input_charset));
        }