public ActionResult Registration(log_in user) { if (ModelState.IsValid) { using (var db = new login_simpleEntities()) { var crypt = new SimpleCrypto.PBKDF2(); int size = crypt.SaltSize; var cryptPass = crypt.Compute(user.pass); log_in newUser = new log_in() { email = user.email, pass = cryptPass, passsalt = crypt.Salt }; db.log_in.Add(newUser); try { db.SaveChanges(); } catch(Exception e) { Debug.Print("Here is the error! " + e.Message); } } } return View(); }
private bool ValidPass(string email, string password) { var crypt = new PBKDF2(); bool isValid = false; using (var db = new login_simpleEntities()) { var user = db.log_in.FirstOrDefault(u => u.email == email); string deCryptPass = crypt.Compute(password, user.passsalt); bool validation = user.pass == deCryptPass; if (user != null) { if (validation) { isValid = true; } } } return isValid; }