public void ShouldEncryptAndDecryptFileCorrectly() { //arrange using (var fileStream = System.IO.File.Open(SourceFilePath, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Write)) { using (var writer = new System.IO.StreamWriter(fileStream)) { writer.Write(TestText); } } //act var aes = new AesEncryptor(); aes.Encode(SourceFilePath, DestinationFilePath, Key); aes.Decode(DestinationFilePath, SourceFilePath, Key); //asserts using (var fileStream = System.IO.File.Open(SourceFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) { using (var reader = new System.IO.StreamReader(fileStream)) { var plainText = reader.ReadToEnd(); Assert.AreEqual(TestText, plainText); } } }
public void Encode(Directory directory) { var aes = new AesEncryptor(); var entryList = (new FileQueueCreator(directory.FullPath)).ListOfFilesInDirectory; var destinationPath = GetDestinationFolderPath(); var key = GetKeyFromDialog(); foreach (var entry in entryList) { aes.Encode(entry, destinationPath + entry.Substring(directory.FullPath.Length), key); } }
public void Encode(File file) { var aes = new AesEncryptor(); aes.Encode(file.FullPath, GetDestinationFilePath(System.IO.Path.GetExtension(file.FullPath)), GetKeyFromDialog()); }