Ejemplo n.º 1
0
 private void detext_Click(object sender, EventArgs e)
 {
     if (name.SelectedItem.ToString() == "RSA")
     {
         Key.Text       = skey[1];
         Plaintext.Text = RSAcipher.DecryptString(Cyphertext.Text, skey[1]);
     }
     if (Cyphertext.Text.Trim() != string.Empty)
     {
         if (Key.Text.Trim() != string.Empty)
         {
             if (name.SelectedItem.ToString() == "Caesar cipher")
             {
                 int k = Convert.ToInt32(this.Key.Text);
                 Plaintext.Text = Caecar.Caecarcipher.DeCaesar(Cyphertext.Text, k);
             }
             else if (name.SelectedItem.ToString() == "DES")
             {
                 Plaintext.Text = DEScipher.Decrypt(Cyphertext.Text, Key.Text);
             }
             else if (name.SelectedItem.ToString() == "Permutation cipher")
             {
                 if (order.Text.ToString() != string.Empty)
                 {
                     Plaintext.Text = permutation.permutationcipher.decrypt(Cyphertext.Text, order.Text, Convert.ToInt32(Key.Text));
                 }
                 else
                 {
                     MessageBox.Show(this, "请输入密钥顺序!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else if (name.SelectedItem.ToString() == "AutoKey cipher")
             {
                 Plaintext.Text = Autokeycipher.decryption(Cyphertext.Text, Key.Text);
             }
             else if (name.SelectedItem.ToString() == "Keyword cipher")
             {
                 Plaintext.Text = Keywordcipher.decrypt(Cyphertext.Text, Key.Text);
             }
             else if (name.SelectedItem.ToString() == "Vigenere cipher")
             {
                 Plaintext.Text = Vigenere.Vigenere.decrypt(Cyphertext.Text, Key.Text);
             }
             else if (name.SelectedItem.ToString() == "Playfair cipher")
             {
                 Plaintext.Text = playfair.Program.Decrypt(Cyphertext.Text, Key.Text);
             }
             else if (name.SelectedItem.ToString() == "CA")
             {
                 if (order.Text.ToString() != string.Empty)
                 {
                     Plaintext.Text = CA.CA.decrypt(Cyphertext.Text, order.Text, Convert.ToInt32(Key.Text));
                 }
                 else
                 {
                     MessageBox.Show(this, "请输入二进制密钥流!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else if (name.SelectedItem.ToString() == "Column cipher")
             {
                 Plaintext.Text = Column.Column.decrypt(Cyphertext.Text, Key.Text);
             }
         }
         else
         {
             MessageBox.Show(this, "请输入密钥!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show(this, "请输入要解密的文本!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }