コード例 #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(inputKey.Text))
     {
         MessageBox.Show("Key word should be specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         String[] values = inputEncryptedText.Text.Split(' ');
         byte[]   bytes  = new byte[values.Length];
         for (int i = 0; i < values.Length; i++)
         {
             bytes[i] = Byte.Parse(values[i]);
         }
         File.WriteAllBytes(tempOutputFilename, bytes);
         try
         {
             IdeaCrypt.cryptFile(tempOutputFilename, tempInputFilename, inputKey.Text, false);
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         inputPlainText.Text = File.ReadAllText(tempInputFilename);
     }
 }
コード例 #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(inputKey.Text))
     {
         MessageBox.Show("Key word should be specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         File.WriteAllText(tempInputFilename, inputPlainText.Text);
         IdeaCrypt.cryptFile(tempInputFilename, tempOutputFilename, inputKey.Text, true);
         inputEncryptedText.Text = String.Join(" ", File.ReadAllBytes(tempOutputFilename));
     }
 }