private void bOK_Click(object sender, EventArgs e) { if (mainform.Encrypt(tbPassword.Text, Properties.Settings.Default.pcryptkey) == password) { auth = true; Close(); } else { tbPassword.Text = ""; switch (i) { case 0: case 4: tText.Text = "You failed, try again..."; break; case 1: tText.Text = "You failed again, looks like you lost it..."; break; case 2: tText.Text = "You'll have to restart from scratch..."; break; case 3: tText.Text = "Ahahahah :)"; break; } i++; } }
private void bPassword_Click(object sender, EventArgs e) { if (tbGPassword.Text.Trim() == "") { MessageBox.Show(this, "Password can't be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbGPassword.Text = ""; tbGConfirm.Text = ""; } else if (tbGConfirm.Text != tbGPassword.Text) { MessageBox.Show(this, "Password confirmation doesn't match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbGConfirm.Text = ""; } else { if (Settings.Default.password != tbGPassword.Text) { Settings.Default.password = tbGPassword.Text; mainform.XmlConfigSet("password", mainform.Encrypt(Settings.Default.password, Settings.Default.pcryptkey)); string[] bwArgs = { "recrypt", Settings.Default.password }; bwProgress.RunWorkerAsync(bwArgs); recryptpopup = new popupRecrypt(this); recryptpopup.Text = "Applying" + recryptpopup.Text; recryptpopup.ShowDialog(this); Settings.Default.cryptkey = Settings.Default.password; } bGPassword.Enabled = false; } }