Пример #1
0
        public void HillCipherTestNew2By2Analysis()
        {
            HillCipher algorithm = new HillCipher();
            string     key       = algorithm.Analyse(newPlain, newCipher);

            Assert.IsTrue(key.Equals(newKey, StringComparison.InvariantCultureIgnoreCase));
        }
Пример #2
0
        private void HillAnalays_Click(object sender, EventArgs e)
        {
            HillCipher hillcipher = new HillCipher();

            string res = hillcipher.Analyse(HillPlain.Text, HillCipher.Text);

            HILLKey.Text = res;
        }
        public void HillCipherTest2By2Analysis2()
        {
            HillCipher algorithm = new HillCipher();

            List <int> key2 = algorithm.Analyse(plain, cipher);

            for (int i = 0; i < key.Count; i++)
            {
                Assert.AreEqual(key[i], key2[i]);
            }
        }
        public void HillCipherError2()
        {
            HillCipher algorithm = new HillCipher();

            List <int> key2 = algorithm.Analyse(mainPlainError2, mainCipherError2);
        }
Пример #5
0
        public void HillCipherError1()
        {
            HillCipher algorithm = new HillCipher();

            string key2 = algorithm.Analyse(mainPlainError, mainCipherError);
        }
Пример #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text.Contains("Ceaser"))
     {
         Ceaser c   = new Ceaser();
         int    Res = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
         textBox4.Text = Res.ToString();
     }
     else if (comboBox1.Text.Contains("Monoalphabetic"))
     {
         Monoalphabetic c   = new Monoalphabetic();
         string         Res = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("Columnar"))
     {
         Columnar   c   = new Columnar();
         List <int> key = new List <int>();
         for (int i = 0; i < textBox3.Text.Length; i++)
         {
             key.Add(int.Parse(textBox3.Text[i].ToString()));
         }
         List <int> Res = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
         textBox4.Text = Res.ToString();
     }
     else if (comboBox1.Text.Contains("HillCipher"))
     {
         HillCipher c          = new HillCipher();
         List <int> key1       = new List <int>();
         List <int> Plaintext1 = new List <int>();
         string     Res        = "";
         List <int> ResDig     = new List <int>();
         if (textBox5.Text == "2")
         {
             if (char.IsDigit(textBox1.Text[0]) && char.IsDigit(textBox2.Text[0]))
             {
                 for (int i = 0; i < textBox1.Text.Length; i++)
                 {
                     Plaintext1.Add(int.Parse(textBox1.Text[i].ToString()));
                 }
                 for (int i = 0; i < textBox2.Text.Length; i++)
                 {
                     key1.Add(int.Parse(textBox2.Text[i].ToString()));
                 }
                 ResDig        = c.Analyse(Plaintext1, key1);
                 textBox4.Text = ResDig.ToString();
             }
             else
             {
                 Res           = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
                 textBox4.Text = Res;
             }
         }
         else if (textBox5.Text == "3")
         {
             if (char.IsDigit(textBox1.Text[0]) && char.IsDigit(textBox2.Text[0]))
             {
                 for (int i = 0; i < textBox1.Text.Length; i++)
                 {
                     Plaintext1.Add(int.Parse(textBox1.Text[i].ToString()));
                 }
                 for (int i = 0; i < textBox2.Text.Length; i++)
                 {
                     key1.Add(int.Parse(textBox2.Text[i].ToString()));
                 }
                 ResDig        = c.Analyse3By3Key(Plaintext1, key1);
                 textBox4.Text = ResDig.ToString();
             }
             else
             {
                 Res           = c.Analyse3By3Key(textBox1.Text.ToString(), textBox2.Text.ToString());
                 textBox4.Text = Res;
             }
         }
     }
     else if (comboBox1.Text.Contains("RailFence"))
     {
         RailFence c   = new RailFence();
         int       Res = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
         textBox4.Text = Res.ToString();
     }
     else if (comboBox1.Text.Contains("RepeatingKeyVigenere"))
     {
         RepeatingkeyVigenere c = new RepeatingkeyVigenere();
         string Res             = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("AutokeyVigenere"))
     {
         AutokeyVigenere c   = new AutokeyVigenere();
         string          Res = c.Analyse(textBox1.Text.ToString(), textBox2.Text.ToString());
         textBox4.Text = Res;
     }
 }