예제 #1
0
        public void MonoTestEnc3()
        {
            Monoalphabetic algorithm = new Monoalphabetic();
            string         cipher    = algorithm.Encrypt(mainPlain2, mainKey1);

            Assert.IsTrue(cipher.Equals(mainCipher2, StringComparison.InvariantCultureIgnoreCase));
        }
예제 #2
0
        public void MonoTestNewEnc()
        {
            Monoalphabetic algorithm = new Monoalphabetic();
            string         cipher    = algorithm.Encrypt(newPlain, newKey);

            Assert.IsTrue(cipher.Equals(newCipher, StringComparison.InvariantCultureIgnoreCase));
        }
예제 #3
0
        private void MonoEncrypt_Click(object sender, EventArgs e)
        {
            Monoalphabetic mono = new Monoalphabetic();

            string res = mono.Encrypt(MonoPlain.Text, MonoKey.Text);

            MonoCipher.Text = res;
        }
예제 #4
0
        private void ButtonEncrypt_Click(object sender, EventArgs e)
        {
            if (textBoxEncryptOriginal.TextLength == 0)
            {
                return;
            }
            var encrypt = chiper.Encrypt(textBoxEncryptOriginal.Text);

            textBoxEncrypt.Text = encrypt;
        }
예제 #5
0
        public HtmlString MonoalphabeticEncryption(string givenText)
        {
            Monoalphabetic encryptor = new Monoalphabetic();

            return(new HtmlString(encryptor.Encrypt(givenText.ToLower())));
        }
예제 #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text.Contains("Ceaser"))
     {
         Ceaser c   = new Ceaser();
         string Res = c.Encrypt(textBox1.Text.ToString(), int.Parse(textBox3.Text.ToString()));
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("Monoalphabetic"))
     {
         Monoalphabetic c   = new Monoalphabetic();
         string         Res = c.Encrypt(textBox1.Text.ToString(), textBox3.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()));
         }
         string Res = c.Encrypt(textBox1.Text.ToString(), key);
         textBox4.Text = Res;
     }
     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 (char.IsDigit(textBox3.Text[0]) && char.IsDigit(textBox1.Text[0]))
         {
             for (int i = 0; i < textBox1.Text.Length; i++)
             {
                 Plaintext1.Add(int.Parse(textBox1.Text[i].ToString()));
             }
             for (int i = 0; i < textBox3.Text.Length; i++)
             {
                 key1.Add(int.Parse(textBox3.Text[i].ToString()));
             }
             ResDig        = c.Encrypt(Plaintext1, key1);
             textBox4.Text = ResDig.ToString();
         }
         else
         {
             Res           = c.Encrypt(textBox1.Text.ToString(), textBox3.Text.ToString());
             textBox4.Text = Res;
         }
     }
     else if (comboBox1.Text.Contains("PlayFair"))
     {
         PlayFair c   = new PlayFair();
         string   Res = c.Encrypt(textBox1.Text.ToString(), textBox3.Text.ToString());
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("RailFence"))
     {
         RailFence c   = new RailFence();
         string    Res = c.Encrypt(textBox1.Text.ToString(), int.Parse(textBox3.Text.ToString()));
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("RepeatingKeyVigenere"))
     {
         RepeatingkeyVigenere c = new RepeatingkeyVigenere();
         string Res             = c.Encrypt(textBox1.Text.ToString(), textBox3.Text.ToString());
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("AutokeyVigenere"))
     {
         AutokeyVigenere c   = new AutokeyVigenere();
         string          Res = c.Encrypt(textBox1.Text.ToString(), textBox3.Text.ToString());
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("RSA"))
     {
         RSA      c   = new RSA();
         string   s   = textBox1.Text.ToString();
         string[] str = s.Split(' ');
         int      p   = int.Parse(str[0]);
         int      q   = int.Parse(str[1]);
         int      M   = int.Parse(str[2]);
         int      ee  = int.Parse(str[3]);
         int      Res = c.Encrypt(p, q, M, ee);
         textBox4.Text = Res.ToString();
     }
     else if (comboBox1.Text.Contains("AES"))
     {
         AES    c   = new AES();
         string Res = c.Encrypt(textBox1.Text.ToString(), textBox3.Text.ToString());
         textBox4.Text = Res;
     }
     else if (comboBox1.Text.Contains("MD5"))
     {
         MD5    c   = new MD5();
         string Res = c.GetHash(textBox1.Text.ToString());
         textBox4.Text = Res;
     }
 }