public virtual void AssignEncryptionKeyInput(EncryptionKeyInput encryptionKeyInput) { this.FileEncryptor = Factory.CreateFileEncryptor(encryptionKeyInput, this.VaultName); this.FileEncryptor.UpdateMessageAction = message => Screen.Print(message.IsError ? Screen.Colors.Error : Screen.Colors.Normal, message.Description); }
public EncryptedLocalDiskReaderWriter([NotNull] IFileEncryptor fileEncryptor, [NotNull] ICredentialStore credentialStore) { if (fileEncryptor == null) throw new ArgumentNullException(nameof(fileEncryptor)); if (credentialStore == null) throw new ArgumentNullException(nameof(credentialStore)); this.fileEncryptor = fileEncryptor; this.credentialStore = credentialStore; }
public EncryptedLocalDiskReaderWriter([NotNull] IFileEncryptor fileEncryptor, [NotNull] ICredentialStore credentialStore) { if (fileEncryptor == null) { throw new ArgumentNullException(nameof(fileEncryptor)); } if (credentialStore == null) { throw new ArgumentNullException(nameof(credentialStore)); } this.fileEncryptor = fileEncryptor; this.credentialStore = credentialStore; }
public bool HashFiles(string srcPath, string resultFileName, IFileEncryptor fileEncryptor) { var fileProcessor = new RecursiveFileProcessor(); var innerFilesPaths = fileProcessor.GetAllFilesInPath(srcPath); var result = new StringBuilder(); var totalTime = 0d; var totalSize = 0d; var areAllFilesProcessed = true; var areAllFilesProcessedLocker = new object(); Parallel.ForEach(innerFilesPaths, path => { var elapsedTIme = Stopwatch.StartNew(); using (var fileStream = OpenFileStream(path)) { switch (fileStream) { case null when !areAllFilesProcessed: return; case null: lock (areAllFilesProcessedLocker) areAllFilesProcessed = false; return; } var hash = fileEncryptor.Encrypt(fileStream); if (hash is null) { return; } elapsedTIme.Stop(); lock (result) { totalTime += elapsedTIme.ElapsedMilliseconds; totalSize += fileStream.Length; result.AppendLine($"Hash: {hash}\tFileName: {path}"); } } }); result.AppendLine($"Performance: {totalSize / totalTime / 1000} MB/s (by CPU time)"); Console.WriteLine($"Total time: {totalTime}"); Console.WriteLine($"Total tize: {totalSize}"); try { File.WriteAllText(resultFileName, result.ToString()); return(areAllFilesProcessed); } catch (IOException e) { Console.WriteLine(e.Message); } catch (SecurityException e) { Console.WriteLine(e.Message); } return(false); FileStream OpenFileStream(string path) { try { return(File.OpenRead(path)); } catch (IOException e) { Console.WriteLine(e.Message); return(null); } catch (UnauthorizedAccessException e) { Console.WriteLine(e.Message); return(null); } } }
public FileMover(IOptions<DRSConfig> config, ApplicationDbContext db, IFileEncryptor encryptor) { _config = config.Value; _encryptor = encryptor; _db = db; }
public EncryptedPeopleFileGenerator(IFileEncryptor fileEncryptor, PeopleFileGenerator peopleFileGenerator) { this.fileEncryptor = fileEncryptor ?? throw new System.ArgumentNullException(nameof(fileEncryptor)); this.peopleFileGenerator = peopleFileGenerator ?? throw new System.ArgumentNullException(nameof(peopleFileGenerator)); }
public PersonFileGeneratorService(IFileSystem fileSystem, IPersonRepository personRepository, IFileEncryptor fileEncryptor) { this.fileSystem = fileSystem; this.personRepository = personRepository; this.fileEncryptor = fileEncryptor; }
public Launcher(IFileEncryptor fileEncryptor, IListGenerator listGenerator, string vaultName) { this.fileEncryptor = fileEncryptor; this.currentFolder = listGenerator.Generate(vaultName); this.executableMenu = this.BuildExecutableMenu(); }