Ejemplo n.º 1
0
        public InversoGrupal(Texto t, int desplazamiento)
        {
            int    conta  = 0;
            string pedazo = "";

            //string nuevo = "";
            while (t.hayMasTexto())
            {
                if (conta % desplazamiento == 0)
                {
                    Inverso i = new Inverso(new Texto(pedazo));
                    mensajeInverso += i.verTexto();
                    pedazo          = "";
                }
                char c = t.getCaracter();
                if (c != 0)
                {
                    pedazo += c;
                }
                conta++;
            }
            if (pedazo.Length == desplazamiento)
            {
                Inverso i = new Inverso(new Texto(pedazo));
                mensajeInverso += i.verTexto();
            }
            else
            {
                mensajeInverso += pedazo;
            }
        }
Ejemplo n.º 2
0
    protected void OnBtnCifrarClicked(object sender, EventArgs e)
    {
        String entrada = txtPlano.Text;

        //INVERSO
        //Texto texto1 = new Texto(entrada);
        Inverso inverso = new Inverso(new Texto(entrada));

        txtCifradoInverso.Buffer.Text = inverso.verTexto();


        //INVERSO GRUPAL
        int semillaIG = 0;

        //InversoGrupal inversoGrupal = new InversoGrupal(new Texto(entrada),semillaIG);
        if (int.TryParse(txtDesplazamiento.Text, out semillaIG))
        {
            InversoGrupal ig = new InversoGrupal(new Texto(entrada), semillaIG);
            txtCifradoInversoGrupal.Buffer.Text = ig.verMensaje();
        }
        else
        {
            txtCifradoInversoGrupal.Buffer.Text = "El desplazamiento debe ser un numero y debe ser positivo";
        }



        //CESAR
        //Texto texto2 = new Texto(entrada);
        int semillaC = 0;

        if (int.TryParse(txtDesplazamiento.Text, out semillaC))
        {
            Cesar c = new Cesar(new Texto(entrada), semillaC);
            txtCifradoCesar.Buffer.Text = c.verMensaje();
        }
        else
        {
            txtCifradoCesar.Buffer.Text = "El desplazamiento debe ser un numero y debe ser positivo";
        }
    }