コード例 #1
0
        private JDPayDictionary BuildEncryptDic <T>(IJDPayRequest <T> request, IDictionary <string, string> parameters) where T : JDPayResponse
        {
            var signDic = new JDPayDictionary(parameters)
            {
                { VERSION, request.GetApiVersion() },
                { MERCHANT, Options.Merchant },
            };

            var signContent = JDPaySecurity.GetSignContent(signDic);
            var sign        = JDPaySecurity.RSASign(signContent, PrivateKey);

            var encyptDic = new JDPayDictionary
            {
                { VERSION, request.GetApiVersion() },
                { MERCHANT, Options.Merchant },
                { SIGN, sign }
            };

            foreach (var iter in parameters)
            {
                if (!string.IsNullOrEmpty(iter.Value))
                {
                    encyptDic.Add(iter.Key, JDPaySecurity.EncryptECB(iter.Value, DesKey));
                }
            }
            return(encyptDic);
        }
コード例 #2
0
ファイル: JDPayClient.cs プロジェクト: gaoconggit/Payment
        private JDPayDictionary BuildEncryptDic <T>(IJDPayRequest <T> request, IDictionary <string, string> dictionary, JDPayOptions options) where T : JDPayResponse
        {
            var signDic = new JDPayDictionary(dictionary)
            {
                { JDPayContants.VERSION, request.GetApiVersion() },
                { JDPayContants.MERCHANT, options.Merchant }
            };

            var signContent = JDPaySecurity.GetSignContent(signDic);
            var sign        = JDPaySecurity.RSASign(signContent, options.PrivateKey);

            var encyptDic = new JDPayDictionary
            {
                { JDPayContants.VERSION, request.GetApiVersion() },
                { JDPayContants.MERCHANT, options.Merchant },
                { JDPayContants.SIGN, sign }
            };

            foreach (var iter in dictionary)
            {
                if (!string.IsNullOrEmpty(iter.Value))
                {
                    encyptDic.Add(iter.Key, JDPaySecurity.EncryptECB(iter.Value, options.DesKeyBase64));
                }
            }
            return(encyptDic);
        }