Beispiel #1
0
        public static void ExtractAndDecrypt(string file, string password, IAlgorithm decrypter, ProgressBar progress)
        {
            UpdateProgressBar(progress, 10.0);
            Directory.CreateDirectory(Path.GetDirectoryName(file) + "\\EncryptedFiles");
            string rarFile = Path.ChangeExtension(file, ".rar");

            File.Copy(file, rarFile, true);
            UpdateProgressBar(progress, 20.0);

            WinRAR.EXTRACT(rarFile, Path.GetDirectoryName(rarFile) + "\\EncryptedFiles");
            UpdateProgressBar(progress, 40.0);

            int allFiles = (Directory.GetFiles(Path.GetDirectoryName(file) + "\\EncryptedFiles")).Length;
            int i        = 1;

            foreach (string f in Directory.GetFiles(Path.GetDirectoryName(file) + "\\EncryptedFiles"))
            {
                DecryptFile(f, password, Path.GetDirectoryName(file), decrypter);
                UpdateProgressBar(progress, (40 + (i / (double)allFiles) * 30));
                i++;
            }

            cmd.runCommand("rmdir /s /q" + " " + "\"" + Path.GetDirectoryName(rarFile) + "\\EncryptedFiles" + "\"");
            UpdateProgressBar(progress, 85.0);
            File.Delete(rarFile);
            UpdateProgressBar(progress, 100.0);
            MessageBox.Show("File decrypted!", Assembly.GetEntryAssembly().GetName().Name);
            UpdateProgressBar(progress, 0.0);
        }
Beispiel #2
0
        private static void Append(string fileToOver, string[] fileToZip, ProgressBar progress)
        {
            bool   res             = false;
            string currentDir      = Path.GetDirectoryName(fileToOver);
            string copiedFilesPath = currentDir + "\\temp_zip";

            res = tmpFiles(fileToOver, fileToZip);
            UpdateProgressBar(progress, 40.0);
            //compressione FILES & Join
            if (res)
            {
                WinRAR.COMPRESS(Path.ChangeExtension(fileToOver, ".rar"), copiedFilesPath);
                UpdateProgressBar(progress, 70.0);
                joinFiles(fileToOver, progress);
            }
        }
Beispiel #3
0
        public static void OpenWithoutCrypt(string fileToOpen, ProgressBar progress)
        {
            UpdateProgressBar(progress, 10.0);
            Directory.CreateDirectory(Path.GetDirectoryName(fileToOpen) + "\\Files");
            string rarFile = Path.ChangeExtension(fileToOpen, ".rar");

            File.Copy(fileToOpen, rarFile, true);
            UpdateProgressBar(progress, 40.0);
            //estrazione
            WinRAR.EXTRACT(rarFile, Path.GetDirectoryName(rarFile) + "\\Files");
            UpdateProgressBar(progress, 80.0);
            //eliminazione archivio temporaneo
            File.Delete(rarFile);
            UpdateProgressBar(progress, 100.0);
            MessageBox.Show("File extracted! :D", Assembly.GetEntryAssembly().GetName().Name);
            UpdateProgressBar(progress, 0.0);
        }
Beispiel #4
0
        public static void EncryptAndAppend(string fileToOver, string[] fileToZip, string password, IAlgorithm encrypter, ProgressBar progress)
        {
            bool   res             = false;
            string currentDir      = Path.GetDirectoryName(fileToOver);
            string copiedFilesPath = currentDir + "\\temp_zip";

            if (String.IsNullOrWhiteSpace(password))
            {
                MessageBox.Show("Encryption Password Missing! Please retry!", "Missing Password!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }

            UpdateProgressBar(progress, 10.0);

            res = tmpFiles(fileToOver, fileToZip);

            UpdateProgressBar(progress, 20.0);

            int allFile = Directory.GetFiles(copiedFilesPath).Length;
            int i       = 1;

            if (!String.IsNullOrWhiteSpace(password) && res)
            {
                foreach (string s in Directory.GetFiles(copiedFilesPath))
                {
                    EncryptFile(s, password, encrypter);
                    UpdateProgressBar(progress, (20 + ((i / (double)allFile) * 40)));
                    i++;
                }
            }
            else
            {
                MessageBox.Show("Encryption Password Missing! Please retry!", "Missing Password!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }
            //compressione
            WinRAR.COMPRESS(Path.ChangeExtension(fileToOver, ".rar"), copiedFilesPath);
            UpdateProgressBar(progress, 80.0);
            joinFiles(fileToOver, progress);
        }