示例#1
0
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            bool        flag     = false;
            AccountInfo dataById = Account.GetDataById(base.LoginAccount.AutoID);
            string      text     = WebUtils.GetString(this.oldpwd.Text);
            string      @string  = WebUtils.GetString(this.newpwd1.Text);
            string      string2  = WebUtils.GetString(this.newpwd2.Text);
            string      string3  = WebUtils.GetString(this.TextBox3.Text);
            string      string4  = WebUtils.GetString(this.TextBox4.Text);

            if (!string.IsNullOrEmpty(text))
            {
                text = DEncryptUtils.SHA512Encrypt(text);
                if (!base.LoginAccount.Password.Equals(text))
                {
                    base.ShowMsg("原密码不正确!");
                }
                else if (@string.Length < 6)
                {
                    base.ShowMsg("新密码不能少于6个字符!");
                }
                else if (string2 != @string)
                {
                    base.ShowMsg("两次密码输入不一致!");
                }
                else
                {
                    dataById.Password = DEncryptUtils.SHA512Encrypt(@string);
                    flag = true;
                }
            }
            dataById.Email  = string3;
            dataById.Mobile = string4;
            if (Account.Update(dataById))
            {
                if (flag)
                {
                    PageBase.log.AddEvent(base.LoginAccount.AccountName, "管理员修改帐户密码成功", 2);
                    HttpContext.Current.Session["Account"] = null;
                    HttpContext.Current.Session.Remove("Account");
                    FormsAuthentication.SignOut();
                    base.Response.Redirect("/Platform/h5/login");
                }
            }
            else
            {
                PageBase.log.AddEvent(base.LoginAccount.AccountName, "管理员修改帐户资料时发生了错误", 2);
                base.ShowMsg("修改失败,发生不可预知的错误");
            }
        }
示例#2
0
        public void TestUnRevEnc()
        {
            //不可逆加密
            //md5
            string md5 = DEncryptUtils.MD5Encrypt(txt); //md5是2次加密,且会截断字符串,这样网上的暴力破解不了

            Console.WriteLine("MD5:" + md5);
            Assert.AreEqual(md5, DEncryptUtils.MD5Encrypt(txt));

            //sha512 比md5更安全的不可逆加密方法
            string sha512 = DEncryptUtils.SHA512Encrypt(txt);

            Console.WriteLine("sha512:" + sha512);
            Assert.AreEqual(sha512, DEncryptUtils.SHA512Encrypt(txt));
        }
示例#3
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         AccountInfo accountInfo = new AccountInfo();
         if (base.IsEdit)
         {
             accountInfo = SinGooCMS.BLL.Account.GetDataById(base.OpID);
         }
         string @string = WebUtils.GetString(this.TextBox2.Text);
         if (accountInfo.AccountName != "superadmin")
         {
             accountInfo.AccountName = WebUtils.GetString(this.TextBox1.Text);
         }
         accountInfo.Email         = WebUtils.GetString(this.TextBox3.Text);
         accountInfo.Mobile        = WebUtils.GetString(this.TextBox4.Text);
         accountInfo.AutoTimeStamp = System.DateTime.Now;
         if (string.IsNullOrEmpty(accountInfo.AccountName))
         {
             base.ShowMsg("帐户名称不能为空");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 if (string.IsNullOrEmpty(@string))
                 {
                     base.ShowMsg("帐户密码不为空");
                     return;
                 }
                 accountInfo.Password = DEncryptUtils.SHA512Encrypt(@string);
                 accountInfo.IsSystem = false;
                 if (SinGooCMS.BLL.Account.Add(accountInfo) > 0)
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加角色[" + accountInfo.AccountName + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("添加角色失败");
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 if (!string.IsNullOrEmpty(@string))
                 {
                     accountInfo.Password = DEncryptUtils.SHA512Encrypt(@string);
                 }
                 if (SinGooCMS.BLL.Account.Update(accountInfo))
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改角色[" + accountInfo.AccountName + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("修改角色失败");
                 }
             }
         }
     }
 }