Ejemplo n.º 1
0
        private static void EncryptAndSign()
        {
            // 参数构建
            var bizContent =
                "<XML><ToUserId><![CDATA[2088102122494786]]></ToUserId><AppId><![CDATA[2013111100036093]]></AppId><AgreementId><![CDATA[20131111000001895078]]></AgreementId>"
                + "<CreateTime>12334349884</CreateTime>"
                + "<MsgType><![CDATA[image-text]]></MsgType>"
                + "<ArticleCount>1</ArticleCount>"
                + "<Articles>"
                + "<Item>"
                + "<Title><![CDATA[[回复测试加密解密]]></Title>"
                + "<Desc><![CDATA[测试加密解密]]></Desc>"
                + "<Url><![CDATA[http://m.taobao.com]]></Url>"
                + "<ActionName><![CDATA[立即前往]]></ActionName>"
                + "</Item>"
                + "</Articles>" + "<Push><![CDATA[false]]></Push>" + "</XML>";
            var publicKeyPem  = Path.Combine(GetCurrentPath(), "public-key.pem");
            var privateKeyPem = Path.Combine(GetCurrentPath(), "aop-sandbox-RSA-private-c#.pem");

            if (!File.Exists(publicKeyPem))
            {
                throw new FileNotFoundException();
            }
            if (!File.Exists(privateKeyPem))
            {
                throw new FileNotFoundException();
            }
            var responseContent =
                AlipaySignature.encryptAndSign(bizContent, publicKeyPem, privateKeyPem, "UTF-8", true, true);

            Console.Write("resultContent=" + responseContent + "\n\r");
        }
Ejemplo n.º 2
0
        public static void EncryptAndSign()
        {
            string bizContent      = "<XML><ToUserId><![CDATA[2088102122494786]]></ToUserId><AppId><![CDATA[2013111100036093]]></AppId><AgreementId><![CDATA[20131111000001895078]]></AgreementId><CreateTime>12334349884</CreateTime><MsgType><![CDATA[image-text]]></MsgType><ArticleCount>1</ArticleCount><Articles><Item><Title><![CDATA[[回复测试加密解密]]></Title><Desc><![CDATA[测试加密解密]]></Desc><Url><![CDATA[http://m.taobao.com]]></Url><ActionName><![CDATA[立即前往]]></ActionName></Item></Articles><Push><![CDATA[false]]></Push></XML>";
            string alipayPublicKey = GetCurrentPath() + "public-key.pem";
            string cusPrivateKey   = GetCurrentPath() + "aop-sandbox-RSA-private-c#.pem";
            string str             = AlipaySignature.encryptAndSign(bizContent, alipayPublicKey, cusPrivateKey, "UTF-8", isEncrypt: true, isSign: true);

            Console.Write("resultContent=" + str + "\n\r");
        }
Ejemplo n.º 3
0
        public void verifygw_success_response()
        {
            Response.ContentType     = "text/xml";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
            Response.Clear();
            string resp = AlipaySignature.encryptAndSign("<success>true</success><biz_content>" + Config.merchant_public_key + "</biz_content>", Config.alipay_public_key, Config.merchant_private_key, "utf-8", false, true);

            Response.Output.WriteLine(resp);
            Response.End();
        }
Ejemplo n.º 4
0
        public static void EncryptAndSign()
        {
            // 参数构建
            string bizContent = "<XML><ToUserId><![CDATA[2088102122494786]]></ToUserId><AppId><![CDATA[2013111100036093]]></AppId><AgreementId><![CDATA[20131111000001895078]]></AgreementId>"
                                + "<CreateTime>12334349884</CreateTime>"
                                + "<MsgType><![CDATA[image-text]]></MsgType>"
                                + "<ArticleCount>1</ArticleCount>"
                                + "<Articles>"
                                + "<Item>"
                                + "<Title><![CDATA[[回复测试加密解密]]></Title>"
                                + "<Desc><![CDATA[测试加密解密]]></Desc>"
                                + "<Url><![CDATA[http://m.taobao.com]]></Url>"
                                + "<ActionName><![CDATA[立即前往]]></ActionName>"
                                + "</Item>"
                                + "</Articles>" + "<Push><![CDATA[false]]></Push>" + "</XML>";
            string publicKeyPem    = GetCurrentPath() + "public-key.pem";
            string privateKeyPem   = GetCurrentPath() + "aop-sandbox-RSA-private-c#.pem";
            string responseContent = AlipaySignature.encryptAndSign(bizContent, publicKeyPem, privateKeyPem, "UTF-8", true, true);

            System.Console.Write("resultContent=" + responseContent + "\n\r");
        }
Ejemplo n.º 5
0
        public string Handle(string requestContent)
        {
            string bizContent = this.client.FireUserFollowEvent();

            return(AlipaySignature.encryptAndSign(bizContent, this.AliRsaPubKey, this.LocalRsaPriKey, "UTF-8", false, true, true));
        }
Ejemplo n.º 6
0
 public string Handle(string requestContent)
 {
     return(AlipaySignature.encryptAndSign(string.Format("<success>true</success><biz_content>{0}</biz_content>", RsaFileHelper.GetRSAKeyContent(this.LocalRsaPubKey, true)), this.AliRsaPubKey, this.LocalRsaPriKey, "UTF-8", false, true, true));
 }