示例#1
0
 private static void CallEncryption(bool encryption, string filePath, byte[] passwordBytes, ref int progress, BackgroundWorker backgroundWorker)
 {
     try
     {
         bool kryptorExtension = filePath.EndsWith(Constants.EncryptedExtension, StringComparison.Ordinal);
         // Prevent Read-Only file attribute causing errors
         File.SetAttributes(filePath, FileAttributes.Normal);
         if (encryption == true && kryptorExtension == false)
         {
             Encryption.InitializeEncryption(filePath, passwordBytes, backgroundWorker);
             OverwriteDisabled(filePath);
         }
         else if (encryption == false && kryptorExtension == true)
         {
             Decryption.InitializeDecryption(filePath, passwordBytes, backgroundWorker);
         }
         else
         {
             DisplayFileError(filePath, encryption, kryptorExtension);
         }
         ReportProgress.IncrementProgress(ref progress, backgroundWorker);
     }
     catch (Exception ex) when(ExceptionFilters.FileAccessExceptions(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.High);
         DisplayMessage.ErrorResultsText(filePath, ex.GetType().Name, "Unable to set file attributes to normal.");
     }
 }
示例#2
0
        private static void CallShredFilesMethod(string filePath, ref int progress, BackgroundWorker bgwShredFiles)
        {
            try
            {
                File.SetAttributes(filePath, FileAttributes.Normal);
                switch (Globals.ShredFilesMethod)
                {
                case 0:
                    ShredFilesMethods.FirstLast16KiB(filePath);
                    break;

                case 1:
                    // false = use zeros, not ones (used in Infosec Standard 5 Enhanced)
                    ShredFilesMethods.ZeroFill(filePath, false, bgwShredFiles);
                    break;

                case 2:
                    ShredFilesMethods.PseudorandomData(filePath, bgwShredFiles);
                    break;

                case 3:
                    ShredFilesMethods.EncryptionErasure(filePath, bgwShredFiles);
                    break;

                case 4:
                    ShredFilesMethods.InfosecStandard5Enhanced(filePath, bgwShredFiles);
                    break;

                case 5:
                    ShredFilesMethods.PseudorandomData5Passes(filePath, bgwShredFiles);
                    break;
                }
                DeleteFile(filePath);
                ReportProgress.IncrementProgress(ref progress, bgwShredFiles);
            }
            catch (Exception ex) when(ExceptionFilters.FileAccessExceptions(ex))
            {
                Logging.LogException(ex.ToString(), Logging.Severity.High);
                DisplayMessage.ErrorResultsText(filePath, ex.GetType().Name, "Unable to set file attributes to normal. This file has not been shredded.");
            }
        }