Пример #1
0
 private void btnDecrypt_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(inputEncryptedText.Text))
     {
         MessageBox.Show("Input text should not be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (string.IsNullOrWhiteSpace(inputIV.Text))
     {
         MessageBox.Show("IV should be specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (string.IsNullOrWhiteSpace(inputKey.Text))
     {
         MessageBox.Show("Key word should be specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         String[] values = inputEncryptedText.Text.Split(' ');
         byte[] input = new byte[values.Length];
         for (int i = 0; i < values.Length; i++)
         {
             input[i] = Byte.Parse(values[i]);
         }
         byte[] output = new byte[input.Length];
         Dragon dragon = new Dragon(inputKey.Text, inputIV.Text);
         dragon.process_bytes(input, output);
         inputPlainText.Text = Encoding.Unicode.GetString(output);
     }
 }
Пример #2
0
 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(inputPlainText.Text))
     {
         MessageBox.Show("Input text should not be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (string.IsNullOrWhiteSpace(inputIV.Text))
     {
         MessageBox.Show("IV should be specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (string.IsNullOrWhiteSpace(inputKey.Text))
     {
         MessageBox.Show("Key word should be specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         byte[] input = Encoding.Unicode.GetBytes(inputPlainText.Text);
         output = new byte[input.Length];
         Dragon dragon = new Dragon(inputKey.Text, inputIV.Text);
         dragon.process_bytes(input, output);
         inputEncryptedText.Text = String.Join(" ", output);
     }
 }