/// <summary> /// 测试des加密 /// </summary> public void TestDesHelper() { var testStr = "FreshMan"; var enCodeStr = DesHelper.DesEnCode(testStr); var deCodeStr = DesHelper.DesDeCode(enCodeStr); deCodeStr.IsEqualTo(testStr); }
public ActionResult Login(string username, string password, string checkcode) { var code = Session["ValidateCode"]?.ToString(); if (string.IsNullOrEmpty(code) || !code.Equals(checkcode, StringComparison.CurrentCultureIgnoreCase)) { ModelState.AddModelError("error", "验证码错误"); Session["ValidateCode"] = null; return(View()); } password = AesHelper.AesEncrypt(password); var loginInfo = _accountService.UserLogin(username, password); if (loginInfo != null && loginInfo.IsLogin) { string data = JsonConvert.SerializeObject(loginInfo); CookieHelper.SetCookie(StaticFileHelper.UserCookieStr, AesHelper.AesEncrypt(DesHelper.DesEnCode(data))); return(Redirect(ViewBag.RootNode + "/Home/WelCome")); } ModelState.AddModelError("error", "用户名或密码错误"); return(View()); }