Example #1
0
        private void KeyFileLocationText_DragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }

            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (files != null && files.Length != 0)
            {
                KeyFileLocationText.Text = files[0];
                FileOP.LoadKeyFile(KeyFileLocationText.Text);
            }
        }
Example #2
0
 /// <summary>
 /// Opens the dialog for opening a file allows opening of all files to allow any file to be a key file
 /// </summary>
 public static bool SelectKeyFile()
 {
     using (OpenFileDialog openFileDialog = new OpenFileDialog()) {
         openFileDialog.InitialDirectory = "c:\\";
         openFileDialog.Filter           = "All files (*.*)|*.*";
         openFileDialog.FilterIndex      = 2;
         openFileDialog.RestoreDirectory = true;
         //if the result is ok load the file
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             //Get the path of specified file
             FileOP.LoadKeyFile(openFileDialog.FileName);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Example #3
0
 private void Confirm_Click(object sender, EventArgs e)
 {
     if (KeyfileLocation.TextLength > 0)
     {
         if (!Crypto.DecryptFile(FileOP.GetFile(), FileOP.KeyFileToBits(KeyfileLocation.Text)))
         {
             MessageBox.Show("Inncorrect Credentials. Please Try Again.", "Access Denied", MessageBoxButtons.OK);
             KeyfileLocation.ResetText();
         }
         else if (!Crypto.DecryptFile(FileOP.GetFile(), passwordEntry.Text))
         {
             Crypto.EncryptFile(FileOP.GetFile(), FileOP.KeyFileToBits(KeyfileLocation.Text));
             MessageBox.Show("Inncorrect Credentials. Please Try Again.", "Access Denied", MessageBoxButtons.OK);
             KeyfileLocation.ResetText();
         }
         else
         {
             FileOP.LoadKeyFile(KeyfileLocation.Text);
             Crypto.mPassTemp = passwordEntry.Text;
             Compressor.Decompress(FileOP.GetFile());
             TheParent.PerformRefresh(true);
             success = true;
             this.Close();
         }
     }
     else if (!Crypto.DecryptFile(FileOP.GetFile(), passwordEntry.Text))
     {
         MessageBox.Show("Inncorrect Credentials. Please Try Again.", "Access Denied", MessageBoxButtons.OK);
         KeyfileLocation.ResetText();
     }
     else
     {
         Crypto.mPassTemp = passwordEntry.Text;
         Compressor.Decompress(FileOP.GetFile());
         TheParent.PerformRefresh(true);
         success = true;
         this.Close();
     }
 }