Beispiel #1
0
        public ActionResult Test(string id)
        {
            string str  = "<div style='font-size:12px;'>";
            string text = System.IO.File.ReadAllText(Server.MapPath("~/validate.code" + id));

            if (string.IsNullOrEmpty(text))
            {
                throw new UserException("验证授权失败,请检查根目录validate.code文件");
            }
            string key  = "AwEAAbfyNG2IR7IHAJ2v54mCM3QFnOy+NbQ+qg8g3HE8T6RceBoQS65twfI+y7D4B1Bzf58UCsDJe4UgJU4UvNFtSgXy+9OrqBNSkiasCO2gBgAKWRnYXG6DxEerPhJYOQvY1NmRltqAVrYCEwko7bKacUOXmi5XLlDAdtDrXVGfx4dh";
            string rNum = new SoftReg().getRNum();

            text = AESHelper.DecryptString(text, key);
            if (string.IsNullOrEmpty(text))
            {
                throw new UserException("验证授权失败");
            }
            Dictionary <string, object> dictionary = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(text);

            if (dictionary == null)
            {
                throw new UserException("验证授权失败");
            }
            string   str2     = dictionary["code"] as string;
            long     num      = Convert.ToInt64(dictionary["time"]);
            DateTime dateTime = new DateTime(2000, 1, 1, 0, 0, 0).AddSeconds((double)num);

            str  = str + "result_code:" + str2;
            str  = str + "<br >time:" + dateTime.ToString();
            str += "</div>";
            return(Content(str));
        }
 private void Button_Click_Decrypt(object sender, RoutedEventArgs e)
 {
     try
     {
         AesText.Text = AESHelper.DecryptString(AesText.Text, AESHelper.Key128);;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            string sss = string.Empty;

            sss = sss.ToUpper();
            Guid g = Guid.Empty;
            Guid st;

            Guid.TryParse("", out st);
            if (st == g)
            {
                int d = 100;
            }
            string dd = st.ToString();
            //  AddCookie:userid=1c5c92092f73437f8237f480cbff5c6f,SecretToken=451f7e73b80e4ab7b82d0391ca11c046
            string showText = "uhKre535fW3s%2BgrntACvHFAXvaELKiA6wuNk5z1q8sv%2FBQRg1%2FL88F8FfdmwgwK3";
            string uid2     = "1c5c92092f73437f8237f480cbff5c6f";

            string code = "451f7e73b80e4ab7b82d0391ca11c046";
            string ss   = AESHelper.EncryptString(uid2, code);
            string uid  = AESHelper.DecryptString(ss, code);
        }
Beispiel #4
0
 private void CheckValidate(Microsoft.AspNetCore.Http.HttpContext httpContextBase)
 {
     try
     {
         if (!File.Exists(new HttpServerUtility(httpContextBase).MapPath("~/validate.code")))
         {
             try
             {
                 string string_ = string.Format("http://auth.cht.com/web/getvalidatecode/?code={0}&isdesigner=Y", new SoftReg().getRNum());
                 Dictionary <string, object> dictionary = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(WebSiteRequest(string_));
                 if (dictionary != null)
                 {
                     string text = dictionary["data"] as string;
                     if (!string.IsNullOrEmpty(text))
                     {
                         File.WriteAllText(new HttpServerUtility(httpContextBase).MapPath("~/validate.code"), text);
                     }
                 }
             }
             catch
             {
             }
         }
         if (!File.Exists(new HttpServerUtility(httpContextBase).MapPath("~/validate.code")))
         {
             throw new UserException("验证授权失败,请检查根目录validate.code文件");
         }
         string ciphertext = File.ReadAllText(new HttpServerUtility(httpContextBase).MapPath("~/validate.code"));
         if (string.IsNullOrEmpty(ciphertext))
         {
             throw new UserException("验证授权失败,请检查根目录validate.code文件");
         }
         string key       = "AwEAAbfyNG2IR7IHAJ2v54mCM3QFnOy+NbQ+qg8g3HE8T6RceBoQS65twfI+y7D4B1Bzf58UCsDJe4UgJU4UvNFtSgXy+9OrqBNSkiasCO2gBgAKWRnYXG6DxEerPhJYOQvY1NmRltqAVrYCEwko7bKacUOXmi5XLlDAdtDrXVGfx4dh";
         string rNum      = new SoftReg().getRNum();
         string plaintext = AESHelper.DecryptString(ciphertext, key);
         if (string.IsNullOrEmpty(plaintext))
         {
             throw new UserException("验证授权失败");
         }
         Dictionary <string, object> dictionary2 = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(plaintext);
         if (dictionary2 == null)
         {
             throw new UserException("验证授权失败");
         }
         string a = dictionary2["code"] as string;
         if (a != rNum)
         {
             throw new UserException("验证授权失败");
         }
         long     num = Convert.ToInt64(dictionary2["time"]);
         DateTime t   = new DateTime(2000, 1, 1, 0, 0, 0).AddSeconds((double)num);
         if (DateTime.Now > t)
         {
             throw new UserException("验证授权失败(已过期)");
         }
     }
     catch
     {
         throw new UserException("验证授权失败");
     }
 }
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="loginID"></param>
        /// <param name="PWD"></param>
        /// <returns></returns>
        public string CHKLogin(string loginID, string PWD)
        {
            if (string.IsNullOrEmpty(loginID))
            {
                return("登录名不能为空");
            }
            if (string.IsNullOrEmpty(PWD))
            {
                return("密码不能为空");
            }
            try
            {
                //解密参数值
                loginID = AESHelper.DecryptString(loginID);
                PWD     = AESHelper.DecryptString(PWD);
                //去掉参数中的转移字符
                loginID = new string((from c in loginID.ToCharArray() where !char.IsControl(c) select c).ToArray());
                PWD     = new string((from c in PWD.ToCharArray() where !char.IsControl(c) select c).ToArray());
                if (string.IsNullOrEmpty(loginID))
                {
                    return("登录名验证失败");
                }
                if (string.IsNullOrEmpty(PWD))
                {
                    return("密码验证失败");
                }
            }
            catch
            { }
            SalonService salon = new SalonService();
            SalonSimple  sal   = salon.GetLoginInfo(loginID, FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "MD5"));

            if (sal.Email == "CCCCCCCCCCCaa")
            {
                sal.Status = 4;
            }
            if (sal == null)
            {
                //return "登陆失败 请检查登录名和密码";
                return("查询失败,或没有查到相关注册信息");
            }
            else
            {
                if (string.IsNullOrEmpty(sal.Uid.ToString()))
                {
                    return("帐号错误");
                }
                else
                {
                    string turl = "";
                    string stat = "1";
                    Session["W_B_UID"] = sal.Uid.ToString();
                    if (sal.Opendate < DateTime.Now)
                    {
                        if (sal.Email != "CCCCCCCCCCCaa")
                        {
                            //如果开通超过1年 那么就是已经过期
                            sal.Status = 3;
                            salon.UpdatestatusInfo(sal.Uid.ToString(), 3);
                        }
                    }
                    switch (sal.Status)
                    {
                    case 0:
                        //帐号禁用
                        turl = "";
                        stat = "登录失败 帐号已被禁用";
                        Session["W_B_UID"] = "";
                        break;

                    case 1:
                        //审核中
                        turl = "/Register/check";
                        break;

                    case 2:
                        //审核未通过
                        turl = "/Register/check";
                        break;

                    case 3:
                        //审核已通过未付款
                        turl = "/Register/check";
                        stat = "2";
                        break;

                    case 4:
                        //审核已通过已付款
                        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                            1,
                            sal.Uid.ToString(),
                            DateTime.Now,
                            DateTime.Now.AddDays(1),
                            false,
                            sal.Cell.Trim() + "$bobo$" + sal.Nickname + "$bobo$" + sal.Logo
                            );
                        string     encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                        HttpCookie authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                        HttpContext.Response.Cookies.Add(authCookie);
                        turl = "/manage/Index";
                        break;
                    }
                    return(stat + "|" + turl);
                }
            }
            return("未知错误");
        }