Example #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            textBox1.Visible = false;
            label1.Visible   = false;
            button5.Visible  = false;

            for (int i = 0; i < ADFGVXTextBoxes.Count() && i < FillADFGVX.Length; i++)
            {
                ADFGVXTextBoxes[i].Text = FillADFGVX[i].ToString();
            }

            MatriceADFGVX = Cell.CreateMatrice(FillADFGVX);

            if (richTextBox2.Text != null && richTextBox2.Text.Length > 0 && richTextBox5.Text != null && richTextBox5.Text.Length > 0 && FormattedMessage.Length > 0)
            {
                string dumb = String.Empty;
                for (int i = 0; i < FormattedMessage.Length; i++)
                {
                    var cell = MatriceADFGVX.FirstOrDefault(x => x.letter == FormattedMessage[i]);
                    dumb += cell.RowLetterV.ToString() + cell.ColumnLetterV.ToString();
                }
                FractionatedMessage = dumb;
            }
            richTextBox3.Text = SpacingByTwo(FractionatedMessage);
        }
Example #2
0
        private string Decrypt()
        {
            DecMatrice = Cell.DecryptionMatrice(KeyToDec, EncryptedMessage);
            string tmpMessage = String.Empty;
            var    matrice    = DecMatrice;

            while (matrice.Count > 0)
            {
                for (int i = 0; i < KeyToDec.Length; i++)
                {
                    var cell = matrice.FirstOrDefault(x => x.KeyLetter == KeyToDec[i]);
                    if (cell != null)
                    {
                        tmpMessage += cell.letter;
                    }
                    matrice.Remove(cell);
                }
            }

            string openText = String.Empty;

            for (int j = 0; j < tmpMessage.Length; j += 2)
            {
                openText += MatriceADFGVX.FirstOrDefault(x => x.RowLetterV == tmpMessage[j] && x.ColumnLetterV == tmpMessage[j + 1]).letter.ToString();
            }

            return(openText.Replace("XMEZERAX", " "));
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Visible = false;
            label1.Visible   = false;
            button5.Visible  = false;

            foreach (var p in ADFGVXTextBoxes)
            {
                p.Enabled = false;
            }
            string mixed = MixedAlphabetADFGVX();

            MatriceADFGVX = Cell.CreateMatrice(mixed);

            for (int i = 0; i < mixed.Length && i < ADFGVXTextBoxes.Count(); i++)
            {
                ADFGVXTextBoxes[i].Text = mixed[i].ToString();
            }

            if (richTextBox2.Text != null && richTextBox2.Text.Length > 0 && richTextBox5.Text != null && richTextBox5.Text.Length > 0 && FormattedMessage.Length > 0)
            {
                string dumb = String.Empty;
                for (int i = 0; i < FormattedMessage.Length; i++)
                {
                    var cell = MatriceADFGVX.FirstOrDefault(x => x.letter == FormattedMessage[i]);
                    dumb += cell.RowLetterV.ToString() + cell.ColumnLetterV.ToString();
                }
                FractionatedMessage = dumb;
            }
            richTextBox3.Text = SpacingByTwo(FractionatedMessage);
        }