Beispiel #1
0
        private void grilla_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.grilla.Columns[e.ColumnIndex].Name == "btnVerContrasenia")
            {
                //comprobar si esta encriptado o en texto normal
                Cuentas   cuentas = new Cuentas();
                DataTable dt      = new DataTable();

                dt = cuentas.BuscarTodosDT(grilla.Rows[e.RowIndex].Cells[0].Value.ToString());

                if (dt.Rows.Count != 0)
                {
                    DataRow row = dt.Rows[0];
                    string  a   = row[2].ToString();
                    string  b   = grilla.Rows[e.RowIndex].Cells[2].Value.ToString();

                    if (a == b)
                    {
                        string hash        = grilla.Rows[e.RowIndex].Cells[0].Value.ToString();
                        string contrasenia = grilla.Rows[e.RowIndex].Cells[2].Value.ToString();

                        string contraseniaDesencriptada = Desencriptar(hash, contrasenia);

                        grilla.Rows[e.RowIndex].Cells[2].Value = contraseniaDesencriptada;
                    }
                    else
                    {
                        string hash        = grilla.Rows[e.RowIndex].Cells[0].Value.ToString();
                        string contrasenia = grilla.Rows[e.RowIndex].Cells[2].Value.ToString();

                        string contraseniaEncriptada = Encriptar(hash, contrasenia);

                        grilla.Rows[e.RowIndex].Cells[2].Value = contraseniaEncriptada;
                    }
                }
            }
        }