Exemplo n.º 1
0
        void bw_normal_onefile_DoWork(object sender, DoWorkEventArgs e)
        {
            DisableAll(true);
            string path = (string)e.Argument;

            try
            {
                List <FileHandle.FileEx> files = new List <FileHandle.FileEx>();
                int i = 1;
                foreach (string item in lstFiles.Items)
                {
                    Log(string.Format("Encrypting {0} | {1}/{2}", Path.GetFileName(item), i, lstFiles.Items.Count), Type.Notice);
                    FileHandle.FileEx file = new FileHandle.FileEx();
                    file.name = Path.GetFileName(item);
                    file.data = File.ReadAllBytes(item);
                    files.Add(file);
                    i++;
                }
                byte[] rawData       = FileHandle.CombineFiles(files.ToArray());
                byte[] encryptedData = Encryption.Encrypt(rawData, txtPassword.Text);
                File.WriteAllBytes(path, encryptedData);
                Log("File(s) encrypted successfully !", Type.Success);
            }
            catch
            {
                Log("Some error occured !", Type.Error);
            }
            DisableAll(false);
        }
Exemplo n.º 2
0
        void bw_portable_DoWork(object sender, DoWorkEventArgs e)
        {
            DisableAll(true);
            string path = (string)e.Argument;

            try
            {
                List <FileHandle.FileEx> files = new List <FileHandle.FileEx>();
                int i = 1;
                foreach (string item in lstFiles.Items)
                {
                    Log(string.Format("Encrypting {0} | {1}/{2}", Path.GetFileName(item), i, lstFiles.Items.Count), Type.Notice);
                    FileHandle.FileEx file = new FileHandle.FileEx();
                    file.name = Path.GetFileName(item);
                    file.data = File.ReadAllBytes(item);
                    files.Add(file);
                    i++;
                }
                byte[] rawData       = FileHandle.CombineFiles(files.ToArray());
                byte[] encryptedData = Encryption.Encrypt(rawData, txtPassword.Text);
                Log("File(s) encrypted successfully !", Type.Success);

                string ResFile = Path.Combine(Application.StartupPath, "Encrypted.resources");
                using (ResourceWriter Writer = new ResourceWriter(ResFile))
                {
                    Writer.AddResource("encfile", encryptedData);
                    Writer.Generate();
                }
                string Source = XProtect.Properties.Resources.stub;
                Compiler.Compile(Source, path, ResFile, null);
                File.Delete(ResFile);
            }
            catch
            {
                Log("Some error occured !", Type.Error);
            }
            DisableAll(false);
        }
Exemplo n.º 3
0
        void bw_normal_eachfile_DoWork(object sender, DoWorkEventArgs e)
        {
            DisableAll(true);
            Stopwatch stp = new Stopwatch();

            stp.Start();
            string path = (string)e.Argument;

            int i = 1;

            foreach (string item in lstFiles.Items)
            {
                try
                {
                    Log(string.Format("Encrypting {0} | {1}/{2}", Path.GetFileName(item), i, lstFiles.Items.Count), Type.Notice);
                    FileHandle.FileEx file = new FileHandle.FileEx {
                        name = Path.GetFileName(item), data = File.ReadAllBytes(item)
                    };
                    byte[] data          = FileHandle.CombineFiles(new FileHandle.FileEx[] { file });
                    byte[] encryptedData = Encryption.Encrypt(data, txtPassword.Text);
                    File.WriteAllBytes(Path.Combine(path, Path.GetFileName(item)), encryptedData);
                    i++;
                }
                catch
                {
                    Log("Some error occured at file !" + Path.GetFileName(item), Type.Error);
                    Thread.Sleep(1500);
                }
            }
            Log("File(s) encrypted successfully !", Type.Success);
            Invoke(new MethodInvoker(delegate
            {
                MessageBox.Show(stp.ElapsedMilliseconds.ToString());
            }));
            DisableAll(false);
        }