Exemple #1
0
 private void encryptButton_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(initialMessage.Text))
     {
         errorProvider1.SetError(initialMessage, "Enter the message you want to encrypt");
     }
     else
     {
         errorProvider1.Clear();
         string clearText  = initialMessage.Text.Trim();
         string cipherText = SecurityEngine.EncryptMessage(clearText, true);
         cipherMessage.Text = cipherText;
     }
 }
Exemple #2
0
        private void decryptButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(encryptedMessage.Text))
            {
                errorProvider1.SetError(encryptedMessage, "Enter the message you want to decrypt");
            }
            else
            {
                errorProvider1.Clear();
                string encryptedText = encryptedMessage.Text.Trim();

                try
                {
                    string decryptedText = SecurityEngine.DecryptMessage(encryptedText, true);
                    decryptedMessage.Text = decryptedText;
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.ToString());
                    MessageBox.Show("This is not an encrypted message. Please make sure to enter an encrypted message.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    Reset();
                }
            }
        }