private void Encrypt(User user) { InitializeEncryptionService(); user.Firstname = _encryptionService.EncryptString(user.Firstname, user.KeyVersion); user.Lastname = _encryptionService.EncryptString(user.Lastname, user.KeyVersion); user.KeyVersion = user.KeyVersion ?? _encryptionService.GetKeyVersion(); }
private void Decrypt(User user) { if (user.KeyVersion.HasValue) { InitializeEncryptionService(); user.Firstname = _encryptionService.DecryptString(user.Firstname, user.KeyVersion.Value); user.Lastname = _encryptionService.DecryptString(user.Lastname, user.KeyVersion.Value); } }
public ActionResult Create(User user) { if (ModelState.IsValid) { _context.Users.Add(user); _context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }