예제 #1
0
        private void decryptFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title = "Select Encrypted File";


            SeedInputBox inputBox = new SeedInputBox();


            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (inputBox.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ThreadStart task = new ThreadStart(delegate
                    {
                        CAEncryption.DecryptFile(dlg.FileName, inputBox.SeedValue);


                        this.EasyInvoke(delegate { this.progressBar1.Value = 0; });


                        MessageBox.Show("File Decrypted");
                    });


                    Thread decryptThread = new Thread(task);
                    decryptThread.Start();
                }
            }
        }
예제 #2
0
        private void encryptFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Title = "Select File To Encrypt";


            SaveFileDialog saveDlg = new SaveFileDialog();

            saveDlg.Title = "Save Encrypted File As..";


            SeedInputBox seedInput = new SeedInputBox();


            if (openDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (seedInput.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (saveDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ThreadStart task = delegate
                        {
                            try
                            {
                                CAEncryption.CreateEncryptedFile(
                                    new System.IO.FileInfo(openDlg.FileName),
                                    saveDlg.FileName,
                                    seedInput.SeedValue
                                    );


                                MessageBox.Show("File Encrypted");


                                this.EasyInvoke(delegate { this.progressBar1.Value = 0; });
                            }
                            catch (Exception ex1)
                            {
                                MessageBox.Show(ex1.Message);
                            }
                        };


                        Thread encryptThread = new Thread(task);
                        encryptThread.Start();
                    }
                }
            }
        }