private void btnAlterar_Click(object sender, EventArgs e) { try { txtSenha.Text = txtSenha.Text.Trim(); txtSenha2.Text = txtSenha2.Text.Trim(); int forca = AvaliarSenha.ObterForca(txtSenha.Text); if (forca < 3) { throw new Exception("A senha é muito fraca."); } if (!txtSenha.Text.Equals(txtSenha2.Text)) { throw new Exception("As senhas não conferem."); } usuario.Senha = Cripto.MD5(txtSenha.Text); usuario.Alteracaosenha = DateTime.Now; usuario.Estado = Estado.NORMAL; gerenciador.Salvar(); MessageBox.Show("Senha alterada com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception er) { lbInfo.Text = er.Message; } }
private void txtSenha_TextChanged(object sender, EventArgs e) { int forca = AvaliarSenha.ObterForca(txtSenha.Text); lbForcaSenha.Text = "Nova senha: (" + AvaliarSenha.ObterForcaString(forca) + ")"; }