Ejemplo n.º 1
0
        private void FolderDecryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MessageBox.Show("Decrypting in background...\n Please wait", "Processing");
            List <string> agms = e.Argument as List <string>;

            foreach (string i in Directory.GetFiles(agms[0], ".", SearchOption.AllDirectories))
            {
                if (i.Contains(".Crypt"))
                {
                    FileEncryption.DecryptFile(i, i.Replace(".Crypt", ""), agms[1]);


                    if (App.FileEncryptPassErr)
                    {
                        break;
                    }
                    else
                    {
                        File.Delete(i);
                    }
                }
            }
            if (!App.FileEncryptPassErr)
            {
                MainWindow.SuccessBox("Folder Decryption completed");
                Application.Current.Shutdown();
            }
            else
            {
                App.FileEncryptPassErr = false;
            }
        }
Ejemplo n.º 2
0
        private void DecryptionDriveThread()
        {
            string[] Files = { };
            this.Dispatcher.Invoke(() =>
            {
                Files = Directory.GetFiles(DriveDecryptionListBox.SelectedItem.ToString(), "*", SearchOption.AllDirectories);
            });


            foreach (string i in Files)
            {
                this.Dispatcher.Invoke(() =>
                {
                    if (i.Contains("Crypt"))
                    {
                        try
                        {
                            FileEncryption.DecryptFile(i, i.Replace("Crypt", ""), FolderDecryptionPassword.Password);
                            CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Decrypted :" + i)));
                            File.Delete(i);
                        }
                        catch (Exception Ex)
                        {
                            ErrorBox(Ex.Message);
                        }
                    }
                });
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("\n")));
            });
        }
Ejemplo n.º 3
0
        private void EncryptionFolderThread()
        {
            string[] Files = {};
            this.Dispatcher.Invoke(() =>
            {
                Files = Directory.GetFiles(FolderEncNameDisplay.Text, "*", SearchOption.AllDirectories);
            });


            foreach (string i in Files)
            {
                this.Dispatcher.Invoke(() =>
                {
                    try
                    {
                        FileEncryption.EncryptFile(i, i + "Crypt", FolderEncryptionPassword.Password);
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + i)));
                        File.Delete(i);
                    }
                    catch (Exception Ex)
                    {
                        ErrorBox(Ex.Message);
                    }
                });
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("\n")));
            });
        }
Ejemplo n.º 4
0
        void DriveDecryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> agms = e.Argument as List <string>;;

            string[] Files = { };
            try
            {
                Files = Directory.GetFiles(agms[0], "*", SearchOption.AllDirectories);
            }
            catch
            {
                ErrorBox("No Drive selected");
                this.Dispatcher.Invoke(() =>
                {
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Decryption Terminated\n")));
                });
                return;
            }

            foreach (string i in Files)
            {
                if (i.Contains(".Crypt"))
                {
                    try
                    {
                        FileEncryption.DecryptFile(i, i.Replace(".Crypt", ""), agms[1]);
                        if (App.FileEncryptPassErr)
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Wrong Password... Decryption Terminated\n")));
                            });
                            break;
                        }
                        this.Dispatcher.Invoke(() =>
                        {
                            CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Decrypted :" + i)));
                        });
                        File.Delete(i);
                    }
                    catch (Exception Ex)
                    {
                        ErrorBox(Ex.Message);
                    }
                }
            }
            if (!App.FileEncryptPassErr)
            {
                this.Dispatcher.Invoke(() =>
                {
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Folder Decryption completed\n")));
                    SuccessBox("Folder Decryption completed");
                });
            }
            else
            {
                App.FileEncryptPassErr = false;
            }
        }
Ejemplo n.º 5
0
        private void DriveEncryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> agms = e.Argument as List <string>;;

            string[] Files = { };
            try
            {
                Files = Directory.GetFiles(agms[0], "*", SearchOption.AllDirectories);
                this.Dispatcher.Invoke(() =>
                {
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Encryption Terminated.\n")));
                });
            }
            catch
            {
                ErrorBox("No drive selected");
                return;
            }
            foreach (string i in Files)
            {
                if (i.Contains(".Crypt"))
                {
                    ErrorBox("This drive contains files that are already encrypted.\nDecrypt those and retry encryption");
                    this.Dispatcher.Invoke(() =>
                    {
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Encryption Terminated.\n")));
                    });
                    return;
                }
            }
            foreach (string i in Files)
            {
                try
                {
                    FileEncryption.EncryptFile(i, i + ".Crypt", agms[1]);
                    this.Dispatcher.Invoke(() =>
                    {
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + i)));
                    });
                    File.Delete(i);
                }
                catch (Exception Ex)
                {
                    ErrorBox(Ex.Message);
                }
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Drive Encryption Completed.\n")));
                SuccessBox("Drive Encryption Completed.");
            });
        }
Ejemplo n.º 6
0
        void FileEncryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> agms = e.Argument as List <string>;

            FileEncryption.EncryptFile(agms[0], agms[0] + ".Crypt", agms[1]);
            if (agms[2].Equals("Delete"))
            {
                File.Delete(agms[0]);
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + FileEncNameDisplay.Text + "\n")));
                SuccessBox("File Encrypted :" + FileEncNameDisplay.Text);
            });
        }
Ejemplo n.º 7
0
 private void EncryptFile_Click(object sender, RoutedEventArgs e)
 {
     if (FileEncNameDisplay.Text.Equals("Not selected"))
     {
         ErrorBox("No File Selected");
     }
     else
     {
         CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Encrypting... Please wait")));
         FileEncryption.EncryptFile(FileEncNameDisplay.Text, FileEncNameDisplay.Text + "Crypt", FileEncryptionPassword.Password);
         if (!(bool)CheckFileEnc.IsChecked)
         {
             File.Delete(FileEncNameDisplay.Text);
         }
         CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + FileEncNameDisplay.Text + "\n")));
     }
 }
Ejemplo n.º 8
0
        private void DecryptFolder_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Decrypting Folder... The screen may freeze.", "Running", MessageBoxButton.OK, MessageBoxImage.Information);
            CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Decrypting folder... This screen might freeze as the process is running in background")));

            foreach (string i in Directory.GetFiles(FolderDecNameDisplay.Text, "*", SearchOption.AllDirectories))
            {
                try
                {
                    FileEncryption.DecryptFile(i, i.Replace("Crypt", ""), FolderDecryptionPassword.Password);
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Decrypted :" + i)));
                    File.Delete(i);
                }
                catch (Exception Ex)
                {
                    ErrorBox(Ex.Message);
                }
            }
            CryptStatus.Document.Blocks.Add(new Paragraph(new Run("\n")));
        }
Ejemplo n.º 9
0
        private void DecryptFile_Click(object sender, RoutedEventArgs e)
        {
            if (FileDecNameDisplay.Text.Equals("Not selected"))
            {
                ErrorBox("No File Selected");
            }
            else
            {
                try
                {
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Decrypting... Please wait")));
                    FileEncryption.DecryptFile(FileDecNameDisplay.Text, FileDecNameDisplay.Text.Replace("Crypt", ""), FileDecryptionPassword.Password);
                    if (!(bool)CheckFileDec.IsChecked && !FileEncryptPassErr)
                    {
                        File.Delete(FileDecNameDisplay.Text);
                    }
                    if (!FileEncryptPassErr)
                    {
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Decrypted :" + FileDecNameDisplay.Text + "\n")));
                    }
                    FileEncryptPassErr = false;
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("The file") && ex.Message.Contains("already exists"))
                    {
                        ErrorBox("A file of the same name exists in that folder!");
                    }

                    else if (ex.Message.Contains("Padding is invalid"))
                    {
                        ErrorBox("Wrong password");
                    }
                    else
                    {
                        ErrorBox(ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 private void Decrypt_Click(object sender, RoutedEventArgs e)
 {
     if ((bool)FileDec.IsChecked)
     {
         FileEncryption.DecryptFile(FilePath, FilePath.Replace(".Crypt", ""), DecryptionPassword.Password);
         if (!App.FileEncryptPassErr)
         {
             MainWindow.SuccessBox("File Decrypted Successfully");
             File.Delete(FilePath);
             Application.Current.Shutdown();
         }
     }
     if ((bool)FolderDec.IsChecked)
     {
         List <string> Agms = new List <string>();
         Agms.Add(FilePath.Replace(FilePath.Split('\\')[FilePath.Split('\\').Length - 1], "").Replace(FilePath.Split('\\')[FilePath.Split('\\').Length - 1], ""));
         Agms.Add(DecryptionPassword.Password);
         BackgroundWorker BW = new BackgroundWorker();
         BW.DoWork += FolderDecryptionbgWorker_DoWork;
         BW.RunWorkerAsync(Agms);
     }
 }
Ejemplo n.º 11
0
        void NewLocFileDecryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> agms = e.Argument as List <string>;

            FileEncryption.DecryptFile(agms[0], agms[4] + "." + agms[0].Split('.')[agms[0].Split('.').Length - 2], agms[1]);
            if (agms[2].Equals("Delete No Err") && !App.FileEncryptPassErr)
            {
                File.Delete(agms[0]);
            }
            else
            {
                File.Delete(agms[0].Replace(".Crypt", ""));
            }
            if (!App.FileEncryptPassErr)
            {
                this.Dispatcher.Invoke(() =>
                {
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Decrypted :" + FileDecNameDisplay.Text + "\n")));
                    SuccessBox("File Decrypted :" + FileDecNameDisplay.Text);
                });
            }
        }