示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox4.Text.Contains("BlowFish Encrypted"))
            {
                BlowFishSvc svc = new BlowFishSvc();

                if (svc.Decrypt(Constants.encryptionKey, textBox4.Text, Constants.decryptedBlowfishPath) == true)
                {
                    textBox5.Text = Constants.decryptedBlowfishPath;
                    MessageBox.Show("File Decrypted");
                    textBox4.Text   = "";
                    button3.Enabled = false;
                }
                return;
            }

            if (textBox4.Text.Contains("TrippleDES Encrypted"))
            {
                TrippleDesSvc svc = new TrippleDesSvc();

                if (svc.Decrypt(Constants.encryptionKey, textBox4.Text, Constants.decryptedTrippleDESPath) == true)
                {
                    textBox5.Text = Constants.decryptedTrippleDESPath;
                    MessageBox.Show("File Decrypted");
                    textBox4.Text   = "";
                    button3.Enabled = false;
                }
                return;
            }

            if (textBox4.Text.Contains("Blowfish & 3DES Encrypted"))
            {
                BlowFish3DesSvc blow3DesSvc = new BlowFish3DesSvc();
                if (blow3DesSvc.Decrypt(Constants.encryptionKey, textBox4.Text, Constants.phase1_decryptedBlowFishTrippleDESPath) == true)
                {
                    File.Delete(Constants.phase1_decryptedBlowFishTrippleDESPath);
                    textBox5.Text = Constants.decryptedTrippleDESPath;
                    MessageBox.Show("File Decrypted");
                    textBox4.Text   = "";
                    button3.Enabled = false;
                }
                return;
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false)
            {
                MessageBox.Show("Please select an encryption type from radio button");
            }

            if (radioButton1.Checked)
            {
                BlowFishSvc svc   = new BlowFishSvc();
                var         watch = System.Diagnostics.Stopwatch.StartNew();

                if (svc.Encrypt(Constants.encryptionKey, textBox4.Text, Constants.encryptedBlowfishPath) == true)
                {
                    watch.Stop();
                    var elapsedMs = watch.ElapsedMilliseconds;
                    textBox1.Text = elapsedMs.ToString();
                    textBox8.Text = new FileInfo(Constants.encryptedBlowfishPath).Length.ToString();
                    textBox5.Text = Constants.encryptedBlowfishPath;
                    MessageBox.Show("File Encrypted Successfully");
                    textBox4.Text   = "";
                    button2.Enabled = false;
                }
                else
                {
                    MessageBox.Show("File Encrypted Failed");
                }

                return;
            }

            if (radioButton2.Checked)
            {
                TrippleDesSvc svc   = new TrippleDesSvc();
                var           watch = System.Diagnostics.Stopwatch.StartNew();
                if (svc.Encrypt(Constants.encryptionKey, textBox4.Text, Constants.encryptedTrippleDESPath) == true)
                {
                    watch.Stop();
                    var elapsedMs = watch.ElapsedMilliseconds;
                    textBox2.Text = elapsedMs.ToString();
                    textBox5.Text = Constants.encryptedTrippleDESPath;
                    textBox7.Text = new FileInfo(Constants.encryptedTrippleDESPath).Length.ToString();
                    MessageBox.Show("File Encrypted Successfully");
                    textBox4.Text   = "";
                    button2.Enabled = false;
                }
                else
                {
                    MessageBox.Show("File Encryption Failed");
                }

                return;
            }

            if (radioButton3.Checked)
            {
                BlowFish3DesSvc blow3desSvc = new BlowFish3DesSvc();
                var             watch       = System.Diagnostics.Stopwatch.StartNew();
                if (blow3desSvc.Encrypt(Constants.encryptionKey, textBox4.Text, Constants.phase1_encryptedBlowFishTrippleDESPath) == true)
                {
                    watch.Stop();
                    var elapsedMs = watch.ElapsedMilliseconds;
                    textBox3.Text = elapsedMs.ToString();
                    File.Delete(Constants.phase1_encryptedBlowFishTrippleDESPath);
                    textBox5.Text = Constants.encryptedTrippleDESPath;
                    textBox6.Text = new FileInfo(Constants.encryptedBlowFishTrippleDESPath).Length.ToString();
                    MessageBox.Show("File Encrypted Successfully");
                    textBox4.Text   = "";
                    button2.Enabled = false;
                }
                else
                {
                    MessageBox.Show("File Encryption Failed");
                }
                return;
            }
        }