예제 #1
0
    /// <summary>
    /// 权检测当前保存的用户是否有效,并为出错信息赋值
    /// </summary>
    /// <returns></returns>
    public bool CheckSAIsValid(out string remind)
    {
        bool flag = false;

        try {
            if (!StationGroup.EnableSA)
            {
                remind = "未开启超级管理员,无法访问该页面";
            }
            else if (string.IsNullOrEmpty(StationGroup.SAName) || string.IsNullOrEmpty(StationGroup.SAPassWord))
            {
                remind = "超级管理员用户名或密码为空,请补齐资料.";
            }
            else if (!ImpersonateValidUser(EncryptHelper.AESDecrypt(StationGroup.SAName), "", EncryptHelper.AESDecrypt(StationGroup.SAPassWord)))
            {
                remind = "超级管理员用户名或密码不正确,请核对资料.";
            }
            else
            {
                flag   = true;
                remind = "当前帐户有效,如果需要更改,请点击编辑";
            }
        }
        catch (Exception ex) { remind = ex.Message; }
        return(flag);
    }
예제 #2
0
        public static void EncryptionTest()
        {
            string plainText  = "pp47026791";
            string cipherText = EncryptHelper.AESEncrypt(plainText);

            plainText = EncryptHelper.AESDecrypt(cipherText);
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            function.WriteErrMsg("页面功能关闭");
            if (!IsPostBack)
            {
                B_User.CheckIsLogged(Request.RawUrl);
                string info = Request.QueryString["Info"];
                if (string.IsNullOrEmpty(info) || DataConverter.CLng(EncryptHelper.AESDecrypt(info)) < 1)
                {
                    function.WriteErrMsg("该页面必须通过邀请才能访问,请联系管理员!!!");
                }
                switch (B_User_Plat.IsPlatUser())
                {
                //case 0://非Plat用户
                //    Response.Redirect("/Plat/Fill.aspx");
                //    break;
                case 1:    //未审核
                    function.WriteErrMsg("你的帐户尚未审核,无法登录能力中心,请联系网络管理员!!!");
                    break;

                case 99:    //正常登录
                    Session["Main_IsPlatUser"] = true;
                    break;
                }
            }
        }
예제 #4
0
        public void AESEncryptTest()
        {
            var key = "SENPARC_KEY";
            {
                //加密-CBC
                var inputBytes = Encoding.UTF8.GetBytes(encypStr);
                var iv         = Encoding.UTF8.GetBytes("SENPARC_IV;SENPA");//16字节

                var encryptResult = Convert.ToBase64String(EncryptHelper.AESEncrypt(inputBytes, iv, key));
                Console.WriteLine("Result:" + encryptResult);
                Assert.AreEqual("Q0l9E//huAwYXzYmxMWusw==", encryptResult);


                //解密-CBC
                inputBytes = Convert.FromBase64String(encryptResult);
                var decryptResult = Encoding.UTF8.GetString(EncryptHelper.AESDecrypt(inputBytes, iv, key));
                Assert.AreEqual(encypStr, decryptResult);
            }

            {
                //加密-CEB
                var encryptResult = EncryptHelper.AESEncrypt(encypStr, key);
                Console.WriteLine("CEB encrypt:" + encryptResult);
                //Assert.AreEqual("raQCWEp5ngocSs5R8srxkg==", encryptResult);
                Assert.IsTrue(encryptResult.Length > 0);

                //解密-CEB
                var cebResult = EncryptHelper.AESDecrypt(encryptResult, key);
                Console.WriteLine("CEB decrypt:" + cebResult);
                Assert.AreEqual(encypStr, cebResult);
            }
        }
예제 #5
0
        static void AESTest()
        {
            Console.WriteLine("===================C# AES-ECB-PKCS7padding Demo===================");
            string str   = "english string to encrypt";
            string enStr = EncryptHelper.AESEncrypt(str);

            Console.WriteLine("Encrypt:\n" + str + "\nto:\n" + enStr);
            Console.WriteLine("========================================================");
            string deStr = EncryptHelper.AESDecrypt(enStr);

            Console.WriteLine("Decrypt:\n" + enStr + "\nto:\n" + deStr);
            Console.WriteLine("========================================================");
            string cnStr   = "锄禾日当午";
            string enCNStr = EncryptHelper.AESEncrypt(cnStr);

            Console.WriteLine("加密::\n" + cnStr + "\n到:\n" + enCNStr);
            Console.WriteLine("========================================================");
            string deCNStr = EncryptHelper.AESDecrypt(enCNStr);

            Console.WriteLine("解密:\n" + enCNStr + "\n到:\n" + deCNStr);
            Console.WriteLine("========================================================");
            string longStr   = "测试要加密的长文本哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
            string enLongStr = EncryptHelper.AESEncrypt(longStr);

            Console.WriteLine("加密::\n" + longStr + "\n到:\n" + enLongStr);
            string deLongStr = EncryptHelper.AESDecrypt(enLongStr);

            Console.WriteLine("解密:\n" + enLongStr + "\n到:\n" + deLongStr);
            Console.WriteLine();
        }
예제 #6
0
    //解析参数,如正确,则显示div让其填充信息
    private void Step2(string code)
    {
        code = code.Trim();
        string     decode = EncryptHelper.AESDecrypt(code);
        string     email  = decode.Split(':')[0];
        int        compid = DataConverter.CLng(decode.Split(':')[1]);
        M_UserInfo mu     = buser.GetSelectByEmail(email);

        if (mu.Remark.Equals(code))//验证通过
        {
            Step3_Div.Visible = true;
            if (compid > 0)//被邀请注册
            {
                compli.Visible      = true;
                CompName_T.ReadOnly = true;
                CompName_T.Text     = compBll.SelReturnModel(compid).CompName;
            }
            else if (compBll.SelCompByMail(email) == 0)
            {
                compli.Visible = true;
            }
            UserName_L.Text = email;
            TrueName_T.Focus();
        }
        else
        {
            function.WriteErrMsg("校验失败,请检测该验证码是否在有效期内!!");
        }
    }
예제 #7
0
        protected void Sure_Btn_Click(object sender, EventArgs e)
        {
            M_UserInfo mu = buser.GetLogin();
            ////------------UserBase
            //bool isExist = true;
            //M_Uinfo muinfo = buser.GetUserBaseByuserid(mu.UserID);
            //if (muinfo == null)
            //{
            //    isExist = false;
            //    muinfo = new M_Uinfo();
            //    muinfo.UserId = mu.UserID;
            //}
            //muinfo.TrueName = TrueName_T.Text;
            //muinfo.Mobile = Mobile_T.Text;
            //muinfo.CompanyName = CompName_T.Text;
            //if (isExist)
            //    buser.UpdateBase(muinfo);
            //else
            //    buser.AddBase(muinfo);
            //------------M_Plat_User
            int compid = Convert.ToInt32(EncryptHelper.AESDecrypt(Request.QueryString["Info"]));

            upMod.UserID     = mu.UserID;
            upMod.CompID     = compid;
            upMod.Mobile     = Mobile_T.Text;
            upMod.TrueName   = TrueName_T.Text;
            upMod.Post       = Post_T.Text;
            upMod.Status     = 0;
            upMod.CreateTime = DateTime.Now;
            upBll.Insert(upMod);
            Response.Redirect("/Plat/Blog/");
        }
예제 #8
0
    /// <summary>
    /// 检查是否开启,用户名与密码是否存在,能否正常登录,并完成正常登录,是否跳转
    /// </summary>
    /// <returns></returns>
    public bool CheckEnableSA(bool needJump = true)
    {
        string remind = "";
        bool   flag   = false;

        if (!StationGroup.EnableSA)
        {
            remind = "未开启超级管理员,无法访问该页面";
        }
        else if (string.IsNullOrEmpty(StationGroup.SAName) || string.IsNullOrEmpty(StationGroup.SAPassWord))
        {
            remind = "超级管理员用户名或密码为空,请补齐资料.";
        }
        else if (!ImpersonateValidUser(EncryptHelper.AESDecrypt(StationGroup.SAName), "", EncryptHelper.AESDecrypt(StationGroup.SAPassWord)))
        {
            remind = "超级管理员用户名或密码不正确,请补齐资料.";
        }
        else
        {
            flag = true;
        }
        if (!flag && needJump)
        {
            HttpContext.Current.Response.Redirect(CustomerPageAction.customPath + "Site/SiteConfig.aspx?remind=" + HttpContext.Current.Server.UrlEncode(remind));
        }
        return(flag);
    }
예제 #9
0
파일: B_User_API.cs 프로젝트: baixue001/IPS
        public void DeOpenID(string openid, ref string uname, ref string upwd)
        {
            string deStr = EncryptHelper.AESDecrypt(openid);

            if (!deStr.Contains(":::"))
            {
                return;
            }
            uname = Regex.Split(deStr, ":::")[0];
            upwd  = Regex.Split(deStr, ":::")[1];
        }
예제 #10
0
        public void AESEncryptForTenpayV3Test()
        {
            var key = "TheKey";//换成你自己的 Key,否则通不过
            {
                //TenPayV3(旧)中的 req_info,换成你自己的 req_info,否则通不过
                var input = "6scm3lyoIZj2YLSVosQsd7xziXw9vJb9w9A5jY0LUNM0O5g9T3MoNgJ5A2xXD26M44rPjGsQXLYxIIxMJWWLPmdXef0xq+b1XKMaKA49H/ft1+82bKPNQS9dYK7RBQ6cvfFjBJMrSvseyWE5ASGfMLg9psnMdU1sC7DMSRSxMRrw7Vzkuvu2QWbK1SA26fehtqHphKoW1pZNy7fDnQb3j+vUeZTDhzbc2g0kspo9JQS60p0L79Aj9Gl15OTreXEplMi4nAU/E4ULptjtF+ylicF0pHKmjsjMufSxYnaBaGZmLlioaigZt1RTWBO90D2NmodFCm7muyGcuCbdfvLhB6Yde8KfVM/yhnC0b42iwi0ASwjCA+jlVIm9ys6Wxrz1lSAXcRF06+ySXgGRXBMpdIitW59Hx4zS0UIATXes9U1TDaZXGYrZDZM02GkqYAX4KiqpmhKC+PNtGrtbPNZbwWWtSl+UE6h4QyPv2cPdRPRMyGlzabauriMiNALF8bDaNTn6K1Nf3tA3nKWh1oemvjCYvT9+mUI8jnyEsXVjnakCOJyKoCIzNgJwliUIV4GXPIauWPFbbG3Tbtm8AAv3FC1yAvdustwLreiXOvOXgvZnSXIV4xLgUfjFWzoc9crwMXd8gJJFW0YAjhF+78WJ4yvDklg/oZnlXUo/ZEnjRdM2AxVTaAHuVNyi3tGMBDustRotkLbAKlR/GW/GaQRF0t8fagJJrEvbOkyrA+NUTCTHOpJ2Yi4YWoj9M2Zar4cXkKixOkx+PpgKMgMffOEnFAe1oTxI8ZwOrxgAjN8O9kPoXecQ2TaP4OyN/4vNxMZMjM/ksmSgAilvEj91PYLme4MY5WjUunLQxdiNx2ZgJj4+b1xyN+thQaYjN34XM97Ao7xZxVlexxN3SspOUvtKQ9Wn3T6c9UAgl184yNYrV/ZJ2xWwpeVyL1H/h29tQxxBjg1SIA1wLda3fRvWIszpqL5OWVUMzQztE4egmVuU8txrMkAEqOhFE1cdzIm7GFJL08IZnMslEs0em/+tJIw8igmQvihNrKwgtDbR78Lsrv84Tpll9qL76PqLrgqaYQuU";

                var md5Str = EncryptHelper.GetLowerMD5(key, Encoding.UTF8);
                var result = EncryptHelper.AESDecrypt(input, md5Str);

                Console.WriteLine(result);
            }
        }
예제 #11
0
        //test
        private void button2_Click(object sender, EventArgs e)
        {
            //string txt=this.GetDbEncryptPwd(this.txtDbOrgPwd.Text);
            //this.txtDbEncryptPwd.Text = txt;

            string orgCode = "HuHaiMing test";
            string key     = "12345678913424234234";

            //MessageBox.Show(EncryptHelper.AESDecrypt(txt, ServerGlobalData.DBConnEncryptKey));
            MessageBox.Show(EncryptHelper.AESDecrypt(EncryptHelper.AESEncrypt(orgCode, key), key));
            //MessageBox.Show(EncryptHelper.DESDecrypt(EncryptHelper.DESEncrypt(orgCode, key), key));
            MessageBox.Show(EncryptHelper.SHA256Encrypt(orgCode));
        }
예제 #12
0
    //最终步
    protected void Sub_Btn_Click(object sender, EventArgs e)
    {
        string     decode = EncryptHelper.AESDecrypt(Request.QueryString["code"]);
        int        compid = DataConverter.CLng(decode.Split(':')[1]);
        M_UserInfo mu     = buser.GetSelectByRemark(Request.QueryString["code"]);

        mu.UserPwd   = StringHelper.MD5(Pwd_T.Text);
        mu.Remark    = "";
        mu.Status    = 0;
        mu.HoneyName = TrueName_T.Text;
        buser.UpDateUser(mu);
        buser.SetLoginState(mu, "Month");
        Response.Redirect("/User/Default.aspx");
    }
        public RedisCacheManager(IConfiguration configuration)
        {
            string redisConfiguration = configuration.GetConnectionString("Redis");

            // string redisConfiguration = Appsettings.app(new string[] { "AppSettings", "RedisCaching", "ConnectionString" });//获取连接字符串
            //string redisConfiguration = configuration.GetConnectionString("AppSettings:RedisCaching")?? "127.0.0.1:6379";
            if (string.IsNullOrWhiteSpace(redisConfiguration))
            {
                throw new ArgumentException("redis config is empty", nameof(redisConfiguration));
            }
            redisConfiguration          = EncryptHelper.AESDecrypt(redisConfiguration, ConstantKey.Redis_Salt_Key);
            this.redisConnenctionString = redisConfiguration;
            this.redisConnection        = GetRedisConnection();
        }
예제 #14
0
        private static void Main_EncryptHelper(string[] args)
        {
            string str   = "需要加密的字符串12345678";
            string md5_1 = EncryptHelper.Md5(str);
            string md5_2 = EncryptHelper.Md5(str, Encoding.UTF8);

            str = "10086";
            string secretKey_AES = Guid.NewGuid().ToString("N");
            string JiaMi         = EncryptHelper.AESEncrypt(str, secretKey_AES);
            string JieMi         = EncryptHelper.AESDecrypt(JiaMi, secretKey_AES);

            string secretKey_DES = "fsT7ObM1nEnrRAGO1djI2YBi";
            string ivs_DES       = "GUGlYE1g";

            JiaMi = EncryptHelper.DESEncrypt(str, secretKey_DES, ivs_DES);
            JieMi = EncryptHelper.DESDecrypt(JiaMi, secretKey_DES, ivs_DES);
        }
예제 #15
0
        /// <summary>
        /// 对退款通知消息进行解密
        /// </summary>
        /// <param name="str"></param>
        /// <param name="mchKey"></param>
        /// <returns></returns>
        public static string DecodeRefundReqInfo(string reqInfo, string mchKey)
        {
            //参考文档:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_16&index=11

            /*
             * 解密步骤如下:
             *  (1)对加密串A做base64解码,得到加密串B
             *  (2)对商户key做md5,得到32位小写key* ( key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置 )
             *
             *  (3)用key*对加密串B做AES-256-ECB解密(PKCS7Padding)
             */
            var base64Encode = Encoding.UTF8.GetString(Convert.FromBase64String(reqInfo)); //(1)
            var md5Str       = EncryptHelper.GetLowerMD5(mchKey, Encoding.UTF8);           //(2)
            var result       = EncryptHelper.AESDecrypt(base64Encode, md5Str);             //(3)

            return(result);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string s = "";

            if (ia.CheckSAIsValid(out s)) //检测,如果当前未配置管理员与用户,则提示让其配置
            {
                remind.InnerText = s;
            }
            else
            {
                remind.InnerText = s;
            }

            if (!IsPostBack)
            {
                //dPageChk.Checked = SiteConfig.SiteOption.SiteManageMode == 1 ? true : false;
                if (!string.IsNullOrEmpty(Request.QueryString["remind"]))
                {
                    remind.InnerText = Request.QueryString["remind"];
                }
                defaultIP.Text = string.IsNullOrEmpty(StationGroup.DefaultIP) ? "http://" + Request.Url.Host + ":" + Request.Url.Port + "/" : StationGroup.DefaultIP;
                //throw new Exception(EncryptHelper.AESDecrypt(StationGroup.SAName));
                try { adminName.Text = EncryptHelper.AESDecrypt(StationGroup.SAName); } catch { }
                //adminPasswd.Attributes.Add("Value",EncryptHelper.AESDecrypt(StationGroup.SAPassWord));
                //defaultIP.Text = sg.DefaultIP;
                //serverIP.Text = enHelper.GetServerIP();
                //------IDC配置
                newNetClientID.Text             = StationGroup.newNetClientID;
                newNetApiPasswd.Text            = StationGroup.newNetApiPasswd;
                nodeIDT.Text                    = StationGroup.NodeID;
                modelIDT.Text                   = StationGroup.ModelID;
                dnsOutputPath.Text              = StationGroup.DnsOutputPath;
                autoCreatedbRadio.SelectedValue = StationGroup.AutoCreateDB.ToString();
                dbm_NameT.Text                  = StationGroup.DBManagerName;
                tDomNameT.Text                  = StationGroup.TDomName;
                if (!string.IsNullOrEmpty(StationGroup.DnsOption))
                {
                    dns1.Text = StationGroup.DnsOption.Split(',')[0];
                    dns2.Text = StationGroup.DnsOption.Split(',')[1];
                    function.Script(this, "setRadio(" + 1 + ");");
                }
                function.Script(this, "setDefaultCheck('" + StationGroup.DefaultDisplay + "','Div3');setDefaultCheck('" + StationGroup.DefaultCheck + "','Div4');");
            }
        }
예제 #17
0
    //创建用户,并发送邮件,email:compid:时间戮
    protected void Step1_Btn_Click(object sender, EventArgs e)
    {
        int compid = 0;

        if (!string.IsNullOrEmpty(Request.QueryString["Invite"]))
        {
            string invite = Request.QueryString["Invite"];
            compid = DataConverter.CLng(EncryptHelper.AESDecrypt(invite).Split(':')[0]);
        }
        Email_T.Text = Email_T.Text.Trim();
        string      code     = B_Plat_Common.GetTimeStamp(Email_T.Text + ":" + compid);
        string      url      = SiteConfig.SiteInfo.SiteUrl.TrimEnd('/') + "/User/RegPlat.aspx?code=" + code;
        string      emailTlp = mailBll.SelByType(B_MailManage.MailType.PlatReg); //SiteConfig.UserConfig.EmailPlatReg;
        MailAddress adMod    = new MailAddress(Email_T.Text);
        MailInfo    mailInfo = new MailInfo()
        {
            ToAddress = adMod, IsBodyHtml = true
        };

        mailInfo.FromName = SiteConfig.SiteInfo.SiteName;
        mailInfo.Subject  = SiteConfig.SiteInfo.SiteName + "注册邮件";
        mailInfo.MailBody = new OrderCommon().TlpDeal(emailTlp, GetPlatRegDt(url, Email_T.Text));
        if (SendMail.Send(mailInfo) == SendMail.MailState.Ok)//发送成功,生成用户,显示下一步提示
        {
            M_UserInfo mu = new M_UserInfo();
            //if (buser.IsExistMail(Email_T.Text)) { function.WriteErrMsg("帐号错误请检查注册选项或联系官方!!"); }
            mu.Email    = Email_T.Text;
            mu.UserName = Email_T.Text;//OK后再更改用户名
            mu.UserPwd  = function.GetRandomString(6);
            mu.Question = "尚未定义问题";
            mu.Answer   = function.GetRandomString(6);
            mu.RegTime  = DateTime.Now;
            mu.Status   = 1;
            mu.Remark   = code;
            buser.AddModel(mu);
            MailSite_A.NavigateUrl = B_Plat_Common.GetMailSite(mu.Email);
            function.Script(this, "showme();");
        }
        else
        {
            function.WriteErrMsg("邮件发送失败,请检测邮箱地址是否正确!!");
        }
    }
예제 #18
0
        /// <summary>
        /// 测试连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //获取
            string miwen = textBox2.Text.Trim();
            //解密
            string mingwen = EncryptHelper.AESDecrypt(miwen);
            //测试
            SqlConnection conn = new SqlConnection(mingwen);

            conn.Open();
            if (ConnectionState.Open == conn.State)
            {
                MessageBox.Show("连接成功");
            }
            else
            {
                MessageBox.Show("连接失败");
            }
            conn.Close();
        }
예제 #19
0
 public string Decrypt(string input, string key)
 {
     return(EncryptHelper.AESDecrypt(input, key));
 }
예제 #20
0
        public string Service()
        {
            //获取配置文件中的数据
            var token          = "";
            var encodingAESKey = "";
            var appId          = "";

            bool isGet  = string.Equals(HttpContext.Request.Method, HttpMethod.Get.Method, StringComparison.OrdinalIgnoreCase);
            bool isPost = string.Equals(HttpContext.Request.Method, HttpMethod.Post.Method, StringComparison.OrdinalIgnoreCase);

            if (!isGet && !isPost)
            {
                return("");
            }

            bool isEncrypt = false;

            try
            {
                var    query = HttpContext.Request.QueryString.ToString();
                string msg_signature = "", nonce = "", timestamp = "", encrypt_type = "", signature = "", echostr = "";

                if (!string.IsNullOrEmpty(query))//需要验证签名
                {
                    var collection = HttpUtility.ParseQueryString(query);
                    msg_signature = collection["msg_signature"]?.Trim();
                    nonce         = collection["nonce"]?.Trim();
                    timestamp     = collection["timestamp"]?.Trim();
                    encrypt_type  = collection["encrypt_type"]?.Trim();
                    signature     = collection["signature"]?.Trim();
                    echostr       = collection["echostr"]?.Trim();

                    if (!string.IsNullOrEmpty(encrypt_type))                                         //有使用加密
                    {
                        if (!string.Equals(encrypt_type, "aes", StringComparison.OrdinalIgnoreCase)) //只支持AES加密方式
                        {
                            return("");
                        }
                        isEncrypt = true;
                    }
                }

                //先验证签名
                if (!string.IsNullOrEmpty(signature))
                {
                    //字符加密
                    var sha1 = MakeSign(nonce, timestamp, token);
                    if (!sha1.Equals(signature, StringComparison.OrdinalIgnoreCase))//验证不通过
                    {
                        return("");
                    }

                    if (isGet)//是否Get请求,如果true,那么就认为是修改服务器回调配置信息
                    {
                        return(echostr);
                    }
                }
                else
                {
                    return("");//没有签名,请求直接返回
                }

                var body = new StreamReader(HttpContext.Request.Body).ReadToEnd();

                if (isEncrypt)
                {
                    XDocument doc     = XDocument.Parse(body);
                    var       encrypt = doc.Element("xml").Element("Encrypt");

                    //验证消息签名
                    if (!string.IsNullOrEmpty(msg_signature))
                    {
                        //消息加密
                        var sha1 = MakeMsgSign(nonce, timestamp, encrypt.Value, token);
                        if (!sha1.Equals(msg_signature, StringComparison.OrdinalIgnoreCase))//验证不通过
                        {
                            return("");
                        }
                    }

                    body = EncryptHelper.AESDecrypt(encrypt.Value, encodingAESKey);//解密
                }

                if (!string.IsNullOrEmpty(body))
                {
                    //
                    //在这里根据body中的MsgType和Even来区分消息,然后来处理不同的业务逻辑
                    //
                    //

                    //result是上面逻辑处理完成之后的待返回结果,如返回文本消息:
                    var result = @"<xml>
                                      <ToUserName><![CDATA[toUser]]></ToUserName>
                                      <FromUserName><![CDATA[fromUser]]></FromUserName>
                                      <CreateTime>12345678</CreateTime>
                                      <MsgType><![CDATA[text]]></MsgType>
                                      <Content><![CDATA[你好]]></Content>
                                    </xml>";
                    if (!string.IsNullOrEmpty(result))
                    {
                        if (isEncrypt)
                        {
                            result = EncryptHelper.AESEncrypt(result, encodingAESKey, appId);
                            var _msg_signature = MakeMsgSign(nonce, timestamp, result, token);
                            result = $@"<xml>
                                                    <Encrypt><![CDATA[{result}]]></Encrypt>
                                                    <MsgSignature>{_msg_signature}</MsgSignature>
                                                    <TimeStamp>{timestamp}</TimeStamp>
                                                    <Nonce>{nonce}</Nonce>
                                                </xml>";
                        }
                        return(result);
                    }

                    //如果这里我们的处理逻辑需要花费较长时间,可以这里先返回空(""),然后使用异步去处理业务逻辑,
                    //异步处理完后,调用微信的客服消息接口通知微信服务器
                }
            }
            catch (Exception ex)
            {
                //记录异常日志
            }

            return("");
        }