private void button1_Click(object sender, EventArgs e) { bool found = false; for (int i = 0; i < userList.Count; i++) { if(textBox1.Text.Equals(userList[i].username)) { string pwd5 = ""; var hash = MD5.Create().ComputeHash(Encoding.Default.GetBytes(maskedTextBox1.Text.ToCharArray())); foreach (byte h in hash) { pwd5 += h.ToString("x2"); } if (pwd5.Equals(userList[i].password)) { uu = userList[i]; found = true; } } } if (found) { this.DialogResult = DialogResult.OK; } else { toolStripStatusLabel1.Text = "Username or password is wrong"; } }
public Users() { InitializeComponent(); string[] uspwd = Properties.Settings.Default.users.Split(';'); uu = new Login(); if (uu.ShowDialog() == System.Windows.Forms.DialogResult.OK) { user = uu.getUser(); for (int i = 0; i < uspwd.Length; i++) { if (uspwd[i].Length > 0) { UserDetails ud = new UserDetails(); string[] ss = uspwd[i].Split(':'); ud.username = ss[0]; ud.password = ss[1]; userList.Add(ud); listView1.Items.Add(ud.username); } } } else { Close(); } }
public Login() { InitializeComponent(); string[] uspwd = Properties.Settings.Default.users.Split(';'); for (int i = 0; i < uspwd.Length; i++) { if(uspwd[i].Length > 0) { UserDetails ud = new UserDetails(); string[] ss = uspwd[i].Split(':'); ud.username = ss[0]; ud.password = ss[1]; userList.Add(ud); } } }