protected override void CryptElement(System.Xml.XmlDocument xml, string hmac)
        {
            try
            {
                string memberCode = xml.SelectSingleNode("//MemberCode").InnerText;

                XmlNode LoginPassword = xml.SelectSingleNode("//LoginPassword");
                //LoginPassword.InnerText = CryptHelper.HMAC_MD5(LoginPassword.InnerText, hmac);
                LoginPassword.InnerText = CryptHelper.MD5(memberCode.Trim().ToLower() + "DimooFighter" + LoginPassword.InnerText.Trim());

                XmlNode NewPassword = xml.SelectSingleNode("//NewPassword");
                //NewPassword.InnerText = CryptHelper.HMAC_MD5(NewPassword.InnerText, hmac);
                NewPassword.InnerText = CryptHelper.MD5(memberCode.Trim().ToLower() + "DimooFighter" + NewPassword.InnerText.Trim());
            }
            catch
            {
            }
        }
Пример #2
0
        protected void ActionToExecute_Click(object sender, EventArgs e)
        {
            InitHead();
            Button btn = (Button)sender;

            switch (btn.ID)
            {
            case "btnHMAC_MD5":
                this.txbMsg.Text = CryptHelper.HMAC_MD5(this.txbMsg.Text.Replace(" ", ""), HMACMD5KEY);
                return;

            case "btnHMAC_DES":
                this.txbMsg.Text = CryptHelper.HMAC_DES(this.txbMsg.Text.Replace(" ", ""), "12345678");
                return;
            }

            ActionToExecute(AParamsData);
        }
Пример #3
0
        private void ActionToExecute(StringBuilder AParamsData)
        {
            string actionName = StringHelper.Extract(AParamsData.ToString(), "<ActionName>", "</ActionName>");

            AParamsData.AppendFormat("<LoginSign>{0}</LoginSign>", LoginSign);
            string APassword = CryptHelper.HMAC_MD5(AParamsData.ToString(), HMACMD5KEY);
            string data      = string.Empty;

            switch (actionName)
            {
            case "LoginSign":
                data = client.DimooActionUserLogin(AParamsData.ToString(), APassword);
                break;

            default:
                data = client.DimooActionToExecute(AParamsData.ToString(), APassword);
                break;
            }

            this.txbMsg.Text = data;
        }
Пример #4
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string body       = context.Request.Form["body"] == null ? null : context.Request.Form["body"].ToString();
                string rt         = context.Request.Form["rt"] == null ? "json" : context.Request.Form["rt"].ToString();
                string HMACMD5KEY = context.Request.Form["hmac"] == null ? null : context.Request.Form["hmac"].ToString();

                if (string.IsNullOrEmpty(body) == false && string.IsNullOrEmpty(HMACMD5KEY) == false)
                {
                    string dataTag   = string.Empty;
                    Regex  regexJson = new Regex(ConstHelper.RegexJson);
                    if (regexJson.IsMatch(body))
                    {
                        dataTag = "json";
                    }

                    Regex regexXml = new Regex(ConstHelper.RegexHtml);
                    if (regexXml.IsMatch(body))
                    {
                        dataTag = "xml";
                    }

                    if (string.IsNullOrEmpty(dataTag))
                    {
                        context.Response.Write("body是未知类型"); return;
                    }

                    ChangeDataProvider provider = new ChangeDataProvider(dataTag);
                    string             data     = provider.Change(body);
                    string             mt       = StringHelper.Extract(data, "<ActionName>", "</ActionName>");

                    CryptDataProvider cryptDataProvider = new CryptDataProvider();
                    data = cryptDataProvider.Crypt(data, HMACMD5KEY);

                    data = data.Replace("<Root>", "").Replace("</Root>", "");

                    DimooActionToExecute dimoo = new DimooActionToExecute();
                    string APassword           = CryptHelper.HMAC_MD5(data, HMACMD5KEY);
                    string result = string.Empty;

                    switch (mt.ToLower())
                    {
                    case "loginsign": result = dimoo.ActionUserLogin(data, APassword); break;

                    default: result = dimoo.ActionToExecute(data, APassword); break;
                    }

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        result = provider.Return(result, rt);
                    }

                    context.Response.Write(result);
                }
                else
                {
                    context.Response.Write("error:请检查必要参数是否准确");
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
            }
        }