Ejemplo n.º 1
0
        private void register_Click(object sender, EventArgs e)
        {
            ClearErrors();

            bool valErrors = ValidateInputs();

            if (!valErrors)
            {
                string passwordPlaintext = PasswordGenerator.Generate();
                string passwordHash      = PasswordHasher.ToHash(passwordPlaintext);

                if (SaveToDB(passwordHash))
                {
                    var message = string.Format("Record created, initial password: {0}", passwordPlaintext);
                    MessageBox.Show(message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                }
                else
                {
                    MessageBox.Show("Failed to save data, please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
 private void btnGeneratePassword_Click(object sender, EventArgs e)
 {
     txtPassword.Text = PasswordGenerator.Generate();
 }