예제 #1
0
 private static string GetEncryptedFilePath(string filePath)
 {
     if (Globals.AnonymousRename == true)
     {
         bool success = OriginalFileName.AppendOriginalFileName(filePath);
         if (success == true)
         {
             return(AnonymousRename.GetAnonymousFileName(filePath) + Constants.EncryptedExtension);
         }
     }
     return(filePath + Constants.EncryptedExtension);
 }
예제 #2
0
 public static bool CreateKeyfile()
 {
     using (var saveFileDialog = new VistaSaveFileDialog())
     {
         saveFileDialog.Title        = "Create Keyfile";
         saveFileDialog.DefaultExt   = ".key";
         saveFileDialog.AddExtension = true;
         saveFileDialog.FileName     = AnonymousRename.GenerateRandomFileName();
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             Globals.KeyfilePath = saveFileDialog.FileName;
             bool success = GenerateKeyfile(Globals.KeyfilePath);
             return(success);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #3
0
 private static void DirectoryEncryption(bool encryption, string folderPath, byte[] passwordBytes, ref int progress, BackgroundWorker backgroundWorker)
 {
     try
     {
         // Anonymise directory names before encryption (if enabled)
         folderPath = AnonymousRename.AnonymiseDirectories(encryption, folderPath);
         // Get all files in all directories
         string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
         // -1 for the selected directory
         Globals.TotalCount += files.Length - 1;
         foreach (string filePath in files)
         {
             CallEncryption(encryption, filePath, passwordBytes, ref progress, backgroundWorker);
         }
         // Deanonymise directory names after decryption (if enabled)
         AnonymousRename.DeanonymiseDirectories(encryption, folderPath);
     }
     catch (Exception ex) when(ExceptionFilters.FileAccessExceptions(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.High);
         DisplayMessage.ErrorResultsText(folderPath, ex.GetType().Name, "Unable to get files in the directory.");
     }
 }