static void Main(string[] args) { //ENTER TEST CODE BELOW..-------------------- Guid guid = new Guid(); string password = "******"; Console.WriteLine(SecurityUtility.EncryptPassword(password)); Console.WriteLine(); Console.WriteLine(SecurityUtility.EncryptPassword(password + guid.ToString())); //------------------------------------------ Console.ReadLine(); }
public ActionResult CreateUser(User user) { if (ModelState.IsValid) { user.UserGuid = Guid.NewGuid(); user.Password = SecurityUtility.EncryptPassword(user.Password + user.UserGuid.ToString()); if (_repository.SaveUser(user)) { TempData["message"] = string.Format("User {0} has been created", user.UserName); return(RedirectToAction("Login")); } } return(View(user)); }
public bool Authenticate(string username, string password) { User result = null; if (username.Equals("Admin")) { result = repo.GetUser().FirstOrDefault(user => user.UserName == username && user.Password == password); } else { Guid userGuid = repo.GetUser().FirstOrDefault(user => user.UserName == username).UserGuid; string guidPassword = password + userGuid.ToString(); string sha1Password = SecurityUtility.EncryptPassword(guidPassword); result = repo.GetUser().FirstOrDefault(user => user.UserName == username && user.Password == sha1Password); } if (result == null) { return(false); } return(true); }