Exemple #1
0
            /// <summary>
            /// The Decryption method.
            /// </summary>
            /// <param name="Source">The string to decrypt.</param>
            /// <param name="password">The password.</param>
            /// <returns>The decrypted string.</returns>
            public string DecryptString(string Source, string password)
            {
                // string plain = testEncrypt.DecryptString(encText, password);

                // 3AES
                AESProvider aes  = AESProvider.Instance;
                string      aes1 = aes.DecryptString(Source, password);
                string      aes2 = aes.DecryptString(aes1, password);
                string      aes3 = aes.DecryptString(aes2, password);

                // 3DES
                DESProvider des  = DESProvider.Instance;
                string      des1 = des.DecryptString(aes3, password);
                string      des2 = des.DecryptString(des1, password);
                string      des3 = des.DecryptString(des2, password);

                // 3RC2
                RC2Provider rc2   = RC2Provider.Instance;
                string      rc2_1 = rc2.DecryptString(des3, password);
                string      rc2_2 = rc2.DecryptString(rc2_1, password);
                string      rc2_3 = rc2.DecryptString(rc2_2, password);

                // 3Rijndael
                RijndaelProvider rp  = RijndaelProvider.Instance;
                string           rp1 = rp.DecryptString(rc2_3, password);
                string           rp2 = rp.DecryptString(rp1, password);
                string           rp3 = rp.DecryptString(rp2, password);

                return(rp3);
            }
Exemple #2
0
        public ActionResult CheckLogin(LoginModel model)
        {
            OperationResult result = new OperationResult(OperationResultType.Warning, "用户名或密码错误");

            var user = UserService.Users.FirstOrDefault(t => t.LoginName == model.LoginName && t.IsDeleted == false);

            if (user != null)
            {
                if (user.Enabled == false)
                {
                    result = new OperationResult(OperationResultType.Warning, "你的账户已经被禁用");
                }
                else if (DESProvider.DecryptString(user.LoginPwd) == model.LoginPwd)
                {
                    //更新User
                    user.LastLoginTime = DateTime.Now;
                    user.LoginCount   += 1;
                    UserService.Update(user);

                    result = new OperationResult(OperationResultType.Success, "登录成功");
                    Session["CurrentUser"] = user;
                    if (result.ResultType == 0)
                    {
                    }
                    Session.Timeout = 20;
                }
            }
            return(Json(result));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var responseURL = From;

            if (String.IsNullOrEmpty(Token))
            {
                Response.Redirect(responseURL);
            }
            else
            {
                string[] tokenValue = DESProvider.DecryptString(Token).Split(',');
                string   name       = tokenValue[0].Trim();
                string   password   = tokenValue[1].Trim();
                string   msg        = String.Empty;
                bool     result     = CustomerHelper.CustomerLogin(Context, name, password, out msg);
                if (result)
                {
                    Response.Redirect(responseURL);
                }
                else
                {
                    string loginURL = YoeJoyConfig.SiteBaseURL + "User/Login.aspx";
                    Response.Write(@"<script type='text/javascript'>alert('" + msg + "');window.location.href = '" + loginURL + "';</script>");
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// The Decryption method.
        /// </summary>
        /// <param name="Source">The string to decrypt.</param>
        /// <param name="password">The password.</param>
        /// <returns>The decrypted string.</returns>
        public string DecryptString(string Source, string password, int[] rKeys)
        {
            // string plain = testEncrypt.DecryptString(encText, password);

            // 3AES
            AESProvider aes  = AESProvider.Instance;
            string      aes1 = aes.DecryptString(Source, password + rKeys[5]);
            string      aes2 = aes.DecryptString(aes1, password + rKeys[4]);
            string      aes3 = aes.DecryptString(aes2, password + rKeys[3]);

            // 3DES
            DESProvider des  = DESProvider.Instance;
            string      des1 = des.DecryptString(aes3, password + rKeys[2]);
            string      des2 = des.DecryptString(des1, password + rKeys[1]);
            string      des3 = des.DecryptString(des2, password + rKeys[0]);

            return(des3);
        }
Exemple #5
0
        public ActionResult CheckPwd(string oldLoginPwd)
        {
            bool result = true;
            var  user   = SessionHelper.GetSession("CurrentUser") as User;

            if (DESProvider.DecryptString(user.LoginPwd) != oldLoginPwd)
            {
                result = false;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
        protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
        {
            if (txtOld.Text.Trim() == "")
            {
                lblErrMsg.Text = "请输入旧密码!";
                return;
            }
            if (txtNew0.Text.Trim() == "" || txtNew1.Text.Trim() == "")
            {
                lblErrMsg.Text = "新的密码不能为空!";
                return;
            }
            if (txtNew0.Text.Trim() != txtNew1.Text.Trim())
            {
                lblErrMsg.Text = "密码输入不一致!";
                return;
            }

            IcsonSessionInfo oSession = CommonUtility.GetUserSession(Context);

            if (oSession.sCustomer == null || oSession.sCustomer.SysNo == AppConst.IntNull)
            {
                Response.Redirect("Login.aspx");
            }

            if (txtOld.Text.Trim() != DESProvider.DecryptString(oSession.sCustomer.Pwd))
            {
                lblErrMsg.Text = "您输入的旧密码与您的旧密码不一致,不能修改。";
            }
            else
            {
                //更新数据库中的用户密码
                Hashtable ht = new Hashtable(2);
                ht.Add("SysNo", oSession.sCustomer.SysNo);
                ht.Add("Pwd", DESProvider.EncryptString(txtNew0.Text.Trim()));
                CustomerManager.GetInstance().Update(ht);

                //更新session中的密码
                oSession.sCustomer.Pwd = txtNew0.Text.Trim();

                lblErrMsg.Text = "修改成功!";
            }
        }
Exemple #7
0
        public ActionResult CheckLogin(LoginModel model)
        {
            OperationResult result = new OperationResult(OperationResultType.Warning, "用户名或密码错误");
            ///是否更换用户
            bool isuser = Request.Cookies["LoginName"] == null ? true : model.Email != Server.HtmlEncode(Request.Cookies["LoginName"].Value);
            ///是否更换密码
            bool ispwd = Request.Cookies["LoginPwd"] == null ? true : model.LoginPwd != Server.HtmlEncode(Request.Cookies["LoginPwd"].Value);

            if (!ispwd)
            {
                try
                {
                    var depwd = DESProvider.DecryptString(model.LoginPwd).Split('_');
                    model.LoginPwd = depwd.Count() == 2 ? depwd[0] : "";
                }
                catch (Exception)
                {
                    Response.Cookies["LoginName"].Expires = System.DateTime.Now.AddSeconds(-1);//Expires过期时间
                    Response.Cookies["LoginPwd"].Expires  = System.DateTime.Now.AddSeconds(-1);
                    return(Json(result));
                }
            }
            //判断是否为加盟店
            if (Tools.IsEmail(model.LoginName))
            {
                //总部
                var user = UserService.Users.Where(t => t.LoginName == model.LoginName && t.IsDeleted == false).FirstOrDefault();
                if (user != null)
                {
                    if (user.Enabled == false)
                    {
                        result = new OperationResult(OperationResultType.Warning, "你的账户已经被禁用");
                    }
                    else if (DESProvider.DecryptString(user.LoginPwd) == model.LoginPwd)
                    {
                        //更新User
                        user.LastLoginTime = DateTime.Now;
                        user.LoginCount   += 1;
                        UserService.Update(user);

                        result = new OperationResult(OperationResultType.Success, "登录成功");
                        SessionModel login = new SessionModel();
                        login.Id               = user._ID;
                        login.LoginName        = user.LoginName;
                        login.RoleIds          = user.RoleIds;
                        Session["CurrentUser"] = login;

                        Session.Timeout = 20;
                    }
                }
            }
            //else
            //{
            //    //加盟店
            //    var store = ShopService.Shops.Where(t => t.code == model.LoginName && t.isDelete == 0).FirstOrDefault();
            //    if (store != null)
            //    {
            //        if (store.password == model.LoginPwd)
            //        {
            //            result = new OperationResult(OperationResultType.Success, "登录成功");
            //            SessionModel login = new SessionModel();
            //            login.Id = store._id.ToString();
            //            login.LoginName = store.code;
            //            //login.Name = store.Name;
            //            login.RoleIds = store.role;
            //            Session["CurrentUser"] = login;

            //            Session.Timeout = 20;
            //        }
            //    }
            //}
            if (isuser && ispwd && result.ResultType == 0 && model.Remember)
            {
                //判断客户端浏览器是否存在该Cookie 存在就先清除
                if (Request.Cookies["LoginName"] != null && Request.Cookies["LoginPwd"] != null)
                {
                    Response.Cookies["LoginName"].Expires = System.DateTime.Now.AddSeconds(-1);//Expires过期时间
                    Response.Cookies["LoginPwd"].Expires  = System.DateTime.Now.AddSeconds(-1);
                }
                //在这里进行密码加密
                model.LoginPwd = DESProvider.EncryptString(model.LoginPwd + "_" + Guid.NewGuid().ToString("N").Substring(0, 5));

                //向客户端浏览器加入Cookie (用户名和密码)
                HttpCookie hcUserName1 = new HttpCookie("LoginName");
                hcUserName1.Expires = DateTime.Now.AddDays(30);
                hcUserName1.Value   = model.LoginName;
                HttpCookie hcPassword1 = new HttpCookie("LoginPwd");
                hcPassword1.Expires = DateTime.Now.AddDays(30);
                hcPassword1.Value   = model.LoginPwd;
                Response.Cookies.Add(hcUserName1);
                Response.Cookies.Add(hcPassword1);
            }
            if (result.ResultType == 0 && !model.Remember)
            {
                Response.Cookies["LoginName"].Expires = System.DateTime.Now.AddSeconds(-1);//Expires过期时间
                Response.Cookies["LoginPwd"].Expires  = System.DateTime.Now.AddSeconds(-1);
            }
            return(Json(result));
        }