Пример #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();
     }
 }
Пример #2
0
        private void frm_encrypt_VisibleChanged(object sender, EventArgs e)
        {
            if (password != null)
            {
                // Encrypt the file
                UnencryptedFile uImageFile = new UnencryptedFile(txt_imgLoc.Text, txt_msgLoc.Text, password);
                uImageFile.Encrypt();
                uImageFile.SaveEncryptedImage(txt_destLoc.Text, imgOutputName, LoadImgFileExt());

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

                // Forget password
                password = null;
            }
        }