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

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

            switch (_sign_type)
            {
            case "MD5":
                mysign = AlipayMD5.Sign(prestr, _key, _input_charset);
                break;

            case "RSA":
                mysign = RSAFromPkcs8.sign(prestr, _private_key, _input_charset);
                break;

            case "0001":
                mysign = RSAFromPkcs8.sign(prestr, _private_key, _input_charset);
                break;

            default:
                mysign = "";
                break;
            }

            return(mysign);
        }
Exemple #2
0
        /// <summary>
        /// 生成请求时的签名Generate the sign
        /// </summary>
        /// <param name="sPara">请求给支付宝的参数数组Parameters to sign</param>
        /// <returns>签名结果sign generated</returns>
        private static string BuildRequestMysign(Dictionary <string, string> sPara)
        {
            //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
            //Rearrange parameters in the data set alphabetically and connect rearranged parameters with & like "parametername=value"
            string prestr = Core.CreateLinkString(sPara);

            //把最终的字符串签名,获得签名结果
            //get the sign
            string mysign = "";

            switch (_sign_type)
            {
            case "RSA":
                mysign = RSAFromPkcs8.sign(prestr, _private_key, _input_charset);
                break;

            default:
                prestr = prestr + Config.md5key;
                mysign = Core.GetAbstractToMD5((Encoding.UTF8.GetBytes(prestr)));
                break;
            }

            return(mysign);
        }
Exemple #3
0
 /// <summary>
 /// 签名--动态读取XML,解析XML数据,返回签名
 /// </summary>
 /// <param name="strXML"></param>
 /// <returns></returns>
 public string RSASignFromXML(string strXML)
 {
     return(RSAFromPkcs8.sign(new AlipayPOS().SignString(strXML), _Private_key));
 }