Example #1
0
        /// <summary>
        /// Evento do botão que ativa todo processo para decifrar a mensagem.
        /// </summary>
        private void btEntrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(TxbCredencial.Text) && String.IsNullOrEmpty(TxbData.Text))
                {
                    throw new Exception("Não é possível decifrar se os dois campos não foram preenchidos");
                }

                else
                {
                    UtilidadePublica CifrasLog   = new UtilidadePublica(TxbData.Text, TxbCredencial.Text.ToLower());
                    Decifrar         decifrar    = new Decifrar(TxbCredencial.Text.ToLower(), TxbData.Text);
                    string           CaminhoPath = CifrasLog.DialogBoxEncontraPasta();
                    this.Close();

                    decifrar.AFBtranscricao = CifrasLog.GerarVetorDoAlfabeto(CifrasLog.LeituraArquivosPMemoria(CaminhoPath, UtilidadePublica.Arquivo.Alfabeto));

                    decifrar.PrimeiroPasso(CifrasLog.LeituraArquivosPMemoria(CaminhoPath, UtilidadePublica.Arquivo.Texto));
                    decifrar.PassaFinal(decifrar.TerceiroPasso(decifrar.SegundoPasso()));
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString(), "Erro Inesperado na Decifragem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #2
0
        //AÇÕES DE BOTÕES
        /// <summary>
        /// Evento de clique no Botão de entrada.
        /// </summary>
        ///<remarks>
        ///Altera a composição de objetos visíveis do form.
        ///Gera uma alfabeto aleatório.
        ///Trata exceções para casos em que os TxtBoxes são vazios.
        ///</remarks>
        private void BtEntrar_Click(object sender, EventArgs e)
        {
            try
            {
                if ((TxbCredencial.Text.Length) < 4)
                {
                    throw new Exception("Desculpe, mas a credencial não pode ser menor que 4 valores.");
                }

                if (!((String.IsNullOrEmpty(TxbCredencial.Text) && String.IsNullOrEmpty(TxbData.Text))))
                {
                    UtilidadePublica Util = new UtilidadePublica(TxbData.Text, TxbCredencial.Text);
                    EstadoEnviar();
                    Util.GerarAlfabetoAleatorio();
                    Util.GerarVetorDoAlfabeto();
                    Util.SalvarTxtStream(Util.DialogSalvarEm(UtilidadePublica.TipoDeSalvar.TxtAlfabeto), 64, true);
                    EncriptaTexto = new Encripitacao(TxbCredencial.Text.ToLower(), Util.AlfabetoMatriz);
                }
                else
                {
                    throw new Exception("Os campos acima não podem estar vazios, ou estão com valores invalidos");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Erro na validação de entrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }