Esempio n. 1
0
 private String Encrypt(String value)
 {
     //algo = new String[] { "RailFence", "MacierzoweA", "MacierzoweB", "MacierzoweC", "CezaraA", "CezaraB", "Vigenere" };
     if (cbAlgorithms.SelectedIndex == -1)
         return "";
     if (cbAlgorithms.SelectedItem.Equals(algo[0]))
     {
         return RailFence.Encrypt(Convert.ToInt32(numericUpDown3.Value), value);
     }
     else if (cbAlgorithms.SelectedItem.Equals(algo[1]))
     {
         return MacierzoweA.Encrypt(textKey.Text, value);
     }
     else if (cbAlgorithms.SelectedItem.Equals(algo[2]))
     {
         return MacierzoweB.Encrypt(textKey.Text, value);
     }
     else if (cbAlgorithms.SelectedItem.Equals(algo[3]))
     {
         return MacierzoweC.Encrypt(textKey.Text, value);
     }
     else if (cbAlgorithms.SelectedItem.Equals(algo[4]))
     {
         return CezaraA.Encrypt(Convert.ToInt32(numericUpDown3.Value), value);
     }
     else if (cbAlgorithms.SelectedItem.Equals(algo[5]))
     {
         return CezaraB.Encrypt(Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown2.Value), value);
     }
     else if (cbAlgorithms.SelectedItem.Equals(algo[6]))
     {
         Vigenere v = new Vigenere(textKey.Text);
         return v.Encrypt(value);
     }
     return "";
 }
Esempio n. 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     Vigenere v = new Vigenere(textKey.Text);
     textResult.Text = v.Decrypt(text.Text);
 }
Esempio n. 3
0
 private String Decrypt(BlockInfo bi, String value)
 {
     //algo = new String[] { "RailFence", "MacierzoweA", "MacierzoweB", "MacierzoweC", "CezaraA", "CezaraB", "Vigenere" };
     if (bi == null)
         return "";
     if (bi.EncryptMethod.Equals(algo[0]))
     {
         return RailFence.Decrypt(Convert.ToInt32(bi.keyOne), value);
     }
     else if (bi.EncryptMethod.Equals(algo[1]))
     {
         return MacierzoweA.Decrypt(bi.keyOne, value);
     }
     else if (bi.EncryptMethod.Equals(algo[2]))
     {
         return MacierzoweB.Decrypt(bi.keyOne, value);
     }
     else if (bi.EncryptMethod.Equals(algo[3]))
     {
         return MacierzoweC.Decrypt(bi.keyOne, value);
     }
     else if (bi.EncryptMethod.Equals(algo[4]))
     {
         return CezaraA.Decrypt(Convert.ToInt32(bi.keyOne), value);
     }
     else if (bi.EncryptMethod.Equals(algo[5]))
     {
         return CezaraB.Decrypt(Convert.ToInt32(bi.keyOne), Convert.ToInt32(bi.keyTwo), value);
     }
     else if (bi.EncryptMethod.Equals(algo[6]))
     {
         Vigenere v = new Vigenere(bi.keyOne);
         return v.Encrypt(value);
     }
     return "";
 }