Ejemplo n.º 1
0
 public static string KeyfilePath(string keyfilePath)
 {
     try
     {
         const string keyfileExtension = ".key";
         // Generate a random keyfile
         if (Directory.Exists(keyfilePath))
         {
             string randomFileName = ObfuscateFileName.GetRandomFileName() + keyfileExtension;
             keyfilePath = Path.Combine(keyfilePath, randomFileName);
         }
         // Append keyfile extension if missing
         if (!keyfilePath.EndsWith(keyfileExtension, StringComparison.InvariantCulture))
         {
             keyfilePath += keyfileExtension;
         }
         Keyfiles.GenerateKeyfile(keyfilePath);
         return(keyfilePath);
     }
     catch (Exception ex) when(ExceptionFilters.FileAccess(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Error);
         DisplayMessage.FilePathException(keyfilePath, ex.GetType().Name, "Unable to randomly generate keyfile.");
         return(null);
     }
 }
 private static string ObfuscateDirectoryName(string directoryPath)
 {
     try
     {
         string directoryName  = Path.GetFileName(directoryPath);
         string obfuscatedPath = ObfuscateFileName.ReplaceFilePath(directoryPath);
         Directory.Move(directoryPath, obfuscatedPath);
         StoreDirectoryName(directoryName, obfuscatedPath);
         return(obfuscatedPath);
     }
     catch (Exception ex) when(ExceptionFilters.FileAccess(ex))
     {
         DisplayMessage.FilePathException(directoryPath, ex.GetType().Name, "Unable to obfuscate directory name.");
         return(directoryPath);
     }
 }
Ejemplo n.º 3
0
 public static string GetOutputFilePath(string inputFilePath)
 {
     try
     {
         if (Globals.ObfuscateFileNames)
         {
             ObfuscateFileName.AppendFileName(inputFilePath);
             inputFilePath = ObfuscateFileName.ReplaceFilePath(inputFilePath);
         }
     }
     catch (Exception ex) when(ExceptionFilters.FileAccess(ex) || ex is EncoderFallbackException)
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Error);
         DisplayMessage.FilePathException(inputFilePath, ex.GetType().Name, "Unable to store file name.");
     }
     return(inputFilePath + Constants.EncryptedExtension);
 }
Ejemplo n.º 4
0
        public static string GetOutputFilePath(string inputFilePath)
        {
            try
            {
                if (Globals.ObfuscateFileNames)
                {
                    ObfuscateFileName.AppendFileName(inputFilePath);
                    inputFilePath = ObfuscateFileName.ReplaceFilePath(inputFilePath);
                }
            }
            catch (Exception ex) when(ExceptionFilters.FileAccess(ex) || ex is EncoderFallbackException)
            {
                DisplayMessage.FilePathException(inputFilePath, ex.GetType().Name, "Unable to store file name.");
            }
            string outputFilePath = inputFilePath + Constants.EncryptedExtension;

            return(FileHandling.GetUniqueFilePath(outputFilePath));
        }