Example #1
0
        public void DecryptBasicTest()
        {
            ADFGVX adfgvx        = new ADFGVX(new CipherNet.Common.Alphabet("PH0QG64MEA1YL2NOFDXKR3CVS5ZW7BJ9UTI8", false), "GERMAN");
            var    encryptedText = adfgvx.Decrypt("FFDVDFADFXXFGFGAVFAFFDXDXFFDVDFFDGGAGVGXVXFAGGDGAXDFADVFXGXX");

            // Starts with as the result could (and will) be padded
            Assert.IsTrue(encryptedText.StartsWith("DEFENDTHEEASTWALLOFTHECASTLE", StringComparison.Ordinal));
        }
Example #2
0
 private void ADFGVXDecrypt(object sender, EventArgs e)
 {
     try
     {
         if (ValidateInputs(EncodeMode.Decrypt))
         {
             var encoder = new ADFGVX(textBox4.Text, textBox3.Text.ToUpper());
             richTextBox2.Text = encoder.Decrypt(richTextBox1.Text);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
        public void Unigraph_ADFGVXTest()
        {
            ADFGVX adfgvx = new ADFGVX(Utility.EnglishAlphabet());

            adfgvx.Square = "phqg0iu7me4ay5lno8jfd9xk6rc2vs4tz1wb3".ToUpper().ToCharArray();
            adfgvx.Key    = "GERMAN";

            for (int i = 0; i < 25; i++)
            {
                generated = adfgvx.GenerateRandomString();

                cipher = adfgvx.Encrypt(generated);
                clear  = adfgvx.Decrypt(cipher);

                Assert.AreEqual(generated, clear);
            }
        }