示例#1
0
        public bool DestroyFolder(Form1 main)
        {
            if (no_valut)
            {
                return(false);
            }
            else
            {
                //destroy the vault and reg settings
                using (var form = new VaultPassword())
                {
                    form.Text            = "Enter password";
                    form.metroTile1.Text = "Open";
                    var result = form.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        password = form.password;
                        if (password == salted_pass)
                        {
                            SetPermission(vault_loc, AccessControlType.Allow);
                            con.RunExternalExe("attrib.exe", "-s -h -r -a " + '"' + vault_loc + '"');
                            EmptyFolder(new DirectoryInfo(vault_loc));
                            Directory.Delete(vault_loc);
                            Registry.LocalMachine.DeleteSubKey(@"SOFTWARE\Netsky Antivirus");

                            MetroFramework.MetroMessageBox.Show(main, "Vault successfully deleted", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            no_valut = true;
                        }
                        else
                        {
                            MetroFramework.MetroMessageBox.Show(main, "Invalid password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                return(true);
            }
        }
示例#2
0
 public void CreateOrUnlockFolder(Form1 main)
 {
     if (no_valut)
     {
         //there's no vault, show user first time info and take vault location and password
         MetroFramework.MetroMessageBox.Show(main, "Please create a folder anywhere in your computer and select the location of that folder. It will be used as vault and put your important files inside that folder to protect and lock it", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         FolderBrowserDialog fbd = new FolderBrowserDialog();
         fbd.ShowNewFolderButton = true;
         fbd.Description         = "Select the folder to make a new vault";
         if (fbd.ShowDialog() == DialogResult.OK)
         {
             using (var form = new VaultPassword())
             {
                 form.Text            = "Create Password";
                 form.metroTile1.Text = "Create";
                 var result = form.ShowDialog();
                 if (result == DialogResult.OK)
                 {
                     password = form.password;
                     con.RunExternalExe("attrib.exe", "+s +h +r +a " + '"' + fbd.SelectedPath + '"');
                     SetPermission(fbd.SelectedPath, AccessControlType.Deny);
                     RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Netsky Antivirus");
                     if (key != null)
                     {
                         key.SetValue("Update", Encrypt(password, hashKey));
                         key.SetValue("UniqueID", Encrypt(fbd.SelectedPath, hashKey));
                     }
                     else
                     {
                         key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Netsky Antivirus");
                         key.SetValue("Update", Encrypt(password, hashKey));
                         key.SetValue("UniqueID", Encrypt(fbd.SelectedPath, hashKey));
                     }
                     no_valut    = false;
                     salted_pass = password;
                     vault_loc   = fbd.SelectedPath;
                     MetroFramework.MetroMessageBox.Show(main, "Vault created successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 } //end if
             }     //end using
         }         //end if
     }
     else
     {
         //vault is there, get key and open it
         using (var form = new VaultPassword())
         {
             form.Text            = "Enter password";
             form.metroTile1.Text = "Open";
             var result = form.ShowDialog();
             if (result == DialogResult.OK)
             {
                 password = form.password;
                 if (password == salted_pass)
                 {
                     SetPermission(vault_loc, AccessControlType.Allow);
                     con.RunExternalExe("attrib.exe", "-s -h -r -a " + '"' + vault_loc + '"');
                     Process.Start(vault_loc);
                 }
                 else
                 {
                     MetroFramework.MetroMessageBox.Show(main, "Invalid password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
 }