public ActionResult SignUp() { //Post var userName = Request.Form["userName"].ToString(); var password = Request.Form["password"].ToString(); var levels = Convert.ToInt32(Request.Form["levels"].ToString()); //Get para verificar que no existe un Usuario con otro Nombre var found = false; var User = new Users(); var login = User.GetLogIn(); foreach (LogInElements elements in login) { if ((elements.UserName == userName)) { found = true; break; } } if (found) { registroValido = 2; return(RedirectToAction("Index")); } else { //método para cifrar la clave ZigZag LogInElements elemento = new LogInElements(); DiffieHellman diffieHellman = new DiffieHellman(); DateTime now = DateTime.Now; var ticks = now.Ticks; var ab = (int)(ticks % 17); var p = 1021; var g = 11; var a = Convert.ToString(ab, 2); a = a.PadLeft(8, '0'); //cifrar a en binario a = User.ZigZagEncryptionCipher(a, levels); //cifrar la contraseña del ususario var CipherPassword = User.ZigZagEncryptionCipher(password, levels); //generar A con diffie Hellman var A = diffieHellman.GenerarClaves(ab, p, g); //elemento a cifrar elemento.Password = CipherPassword; elemento.UserName = userName; elemento.A = Convert.ToString(A); elemento.PrivateKey = a; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:58992/"); var postjob = client.PostAsync("api/LogIn", new StringContent(new JavaScriptSerializer().Serialize(elemento), Encoding.UTF8, "application/json")); postjob.Wait(); registroValido = 1; } return(RedirectToAction("Index")); } }
public IActionResult Put(string id, [FromBody] LogInElements UserElements) { var user = login.Get(id); if (user == null) { return(NotFound()); } login.Modificar(id, UserElements); return(NoContent()); }
public async void Modificar(string id, LogInElements userelements) { await _login.ReplaceOneAsync(users => users.Id == id, userelements); }
public void Post(LogInElements user) { login.Insertar(user); }
public LogInElements Insertar(LogInElements user) { _login.InsertOne(user); return(user); }