Exemplo n.º 1
0
 private void btn_encrypt_Click(object sender, EventArgs e)
 {
     if (txt_textLoc.BackColor == Color.LightGreen && txt_imgLoc.BackColor == Color.LightGreen && txt_destLoc.BackColor == Color.LightGreen)
     {
         if (mainForm.encryptChosen)
         {
             // Encrypt the file
             UnencryptedFile uImageFile = new UnencryptedFile(txt_imgLoc.Text, txt_textLoc.Text);
             uImageFile.Encrypt();
             uImageFile.SaveEncryptedImage(txt_destLoc.Text);
             uImageFile.SavePassword(txt_destLoc.Text);
         }
         else
         {
             // Decrypt the file
             EncryptedFile eImageFile = new EncryptedFile(txt_imgLoc.Text, txt_textLoc.Text);
             eImageFile.Decrypt();
             eImageFile.SaveMessage(txt_destLoc.Text);
         }
     }
     else
     {
         // Play windows error sound
         System.Media.SystemSounds.Exclamation.Play();
     }
 }
Exemplo n.º 2
0
        private void frm_decrypt_VisibleChanged(object sender, EventArgs e)
        {
            if (password != null)
            {
                // Decrypt the file
                EncryptedFile eImageFile = new EncryptedFile(txt_imgLoc.Text, password);
                eImageFile.Decrypt();
                eImageFile.SaveMessage(txt_destLoc.Text, msgOutputName, Properties.Settings.Default.decMsgOutputFormat);

                // Reset all textboxes
                txt_imgLoc.Text  = "";
                txt_destLoc.Text = "";

                // Forget password
                password = null;
            }
        }