private void button1_Click(object sender, EventArgs e) { profile user; user.name = textBox1.Text; user.password = textBox2.Text; user.hashIter = 0; string hashedPassword = ""; ActSelForm newForm = new ActSelForm(user.name); if (ActSelForm.userExists) { if (ActSelForm.isFirstAuthF2) { textBox1.Text = ""; textBox2.Text = ""; this.Hide(); newForm.Owner = this; newForm.Show(); } else { user.hashIter = ActSelForm.getHashIterNumber(); hashedPassword = user.password; for (var i = 0; i < user.hashIter - 1; i++) { using (SHA512 shaM = new SHA512Managed()) { hashedPassword = Encoding.UTF8.GetString(shaM.ComputeHash(Encoding.UTF8.GetBytes(hashedPassword))); } } if (ActSelForm.checkHash(hashedPassword)) { textBox1.Text = ""; textBox2.Text = ""; this.Hide(); newForm.Owner = this; newForm.Show(); } else { label3.Text = "Неверный пароль"; cntFails++; } } } else { label3.Text = "Данного пользователя не существует"; } if (cntFails == 2) { Close(); } }
private void button1_Click(object sender, EventArgs e) { foreach (profile user in dataBase.dBase) { if (user.name.Equals(textBox1.Text.ToString())) { if (user.is_blocked) { label3.Text = "Пользователь " + user.name + " заблокирован"; break; } else { if (user.password == "") { ActSelForm newForm = new ActSelForm(user, true); newForm.Owner = this; textBox1.Text = ""; textBox2.Text = ""; label3.Text = ""; this.Hide(); newForm.Show(); break; } else if (Crypter.DecryptPswd(user.password) == textBox2.Text) { ActSelForm newform = new ActSelForm(user, false); newform.Owner = this; textBox1.Text = ""; textBox2.Text = ""; label3.Text = ""; this.Hide(); newform.Show(); break; } else { if (user.name == prevName) { cntFails++; } else { prevName = user.name; cntFails = 0; } label3.Text = "Неверный пароль"; break; } } } else { label3.Text = "Такого пользователя не существует"; } } if (cntFails == 2) { Close(); } }