//Does The Encryption
        private void button_LockEncr_Click(object sender, EventArgs e)
        {
            try
            {
                DataAccessClass dt = new DataAccessClass();
                //DataAccessClass dt = new DataAccessClass();
                //DataAccessClass dt2 = new DataAccessClass();
                Boolean s = dt.PassKey(textBox_key.Text);

                if (s == true)
                {
                    if (textBox_rKey.Text.Length == 8)
                    {
                        LogicClass lc   = new LogicClass();
                        Boolean    stat = lc.EncryptingMethod(textBox_fLocation.Text, textBox_rKey.Text);
                        if (stat)
                        {
                            MessageBox.Show("Encryption Succesful!", "Encryption", MessageBoxButtons.OK);
                            dt.InsertFileLockList(textBox_fLocation.Text);
                            dt.InsertFileLockPassword(textBox_fLocation.Text, textBox_rKey.Text);
                            MessageBox.Show("Data Inserted into Password Bank", "Done!", MessageBoxButtons.OK);
                            textBox_fLocation.Clear();
                        }
                        else
                        {
                            MessageBox.Show("Encryption Error....", "Error!", MessageBoxButtons.OK);
                        }
                    }

                    else
                    {
                        if (textBox_rKey.Text.Length < 8)
                        {
                            MessageBox.Show("Password is too short. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("Password is too large. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK);
                        }
                    }
                }

                else
                {
                    MessageBox.Show("Locker password is wrong! Please enter the correct one.", "Wrong Password", MessageBoxButtons.OK);
                }
            }

            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, "Error!!", MessageBoxButtons.OK);
            }


            textBox_key.Clear();
            textBox_rKey.Clear();
        }
Example #2
0
        //Does The Encryption
        private void button_LockEncr_Click(object sender, EventArgs e)
        {
            try
            {
                DataAccessClass dt = new DataAccessClass();
                Boolean         s  = dt.PassKey(textBox_key.Text);
                if (s == true && textBox_key.Text == textBox_rKey.Text)
                {
                    LogicClass lc   = new LogicClass();
                    Boolean    stat = lc.EncryptingMethod(textBox_fLocation.Text);
                    if (stat)
                    {
                        MessageBox.Show("Encryption Succesful!", "Encryption", MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Encryption Error....", "Error!", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Wrong Password", "Error!", MessageBoxButtons.OK);
                }
            }

            catch (Exception Ex)
            {
                MessageBox.Show("Invalid Input", "Error!!", MessageBoxButtons.OK);
            }
            DataAccessClass fll = new DataAccessClass();

            fll.InsertFileLockList(textBox_fLocation.Text);
            //textBox_encFile.Clear();
            textBox_fLocation.Clear();
            textBox_key.Clear();
            textBox_rKey.Clear();
            //textBox_key.Text = string.Empty;
        }
        //Button for Locking -------------------------------------------------------------------------------------------------------
        private void btn_Lock_Click(object sender, EventArgs e)
        {
            try
            {
                DataAccessClass dac = new DataAccessClass();
                Boolean         bl  = dac.PassKey(txt_Pass.Text);

                if (bl)
                {
                    if (txtEcryptPass.Text.Length == 8)
                    {
                        string[] files = Directory.GetFiles(txt_FolderPath.Text, "*.*", SearchOption.AllDirectories);
                        //Console.WriteLine("The number of directories starting with p is {0}.", folders.Length);
                        MessageBox.Show("There Are " + files.Length + " files in the diretory....", "Nice!!", MessageBoxButtons.OK);
                        int count = 0;
                        foreach (string file in files)
                        {
                            LogicClass lgCs = new LogicClass();
                            Boolean    s    = lgCs.EncryptingMethod(file, txtEcryptPass.Text);
                            if (s)
                            {
                                count++;
                            }
                        }
                        if (count == files.Length)
                        {
                            MessageBox.Show(count + " Files Have been Locked!!", "Congratzz!!", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("The Folder Has not Locked Properly!", "Error", MessageBoxButtons.OK);
                        }

                        DirectoryInfo d = new DirectoryInfo(fpath);
                        //string selectedpath = d.Parent.FullName + d.Name;
                        if (fpath.LastIndexOf(".{") == -1)
                        {
                            //if (checkBox1.Checked)
                            //setpassword(folderBrowserDialog1.SelectedPath);
                            Status = arr;
                            if (!d.Root.Equals(d.Parent.FullName))
                            {
                                d.MoveTo(d.Parent.FullName + "\\" + d.Name + Status);
                            }
                            else
                            {
                                d.MoveTo(d.Parent.FullName + d.Name + Status);
                            }
                            //textBox1.Text = folderBrowserDialog1.SelectedPath;
                            pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\lock.jpg");


                            dac.InsertHighFolder(txt_FolderPath.Text);
                            dac.InsertHighFolderPassword(txt_FolderPath.Text, txtEcryptPass.Text);
                            MessageBox.Show("The Folder has been successfully Locked!", "Congratulations!", MessageBoxButtons.OK);
                            MessageBox.Show("Data Inserted into Password Bank", "DONE!!", MessageBoxButtons.OK);
                            txt_FolderPath.Clear();
                        }
                    }

                    else
                    {
                        if (txtEcryptPass.Text.Length < 8)
                        {
                            MessageBox.Show("Password is too short. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("Password is too large. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Locker password is wrong! Please enter the correct one.", "Wrong Password!", MessageBoxButtons.OK);
                }

                txt_Pass.Clear();
                txtEcryptPass.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK);
            }
        }