Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        public void Decode(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.Decode(entry, destinationPath + entry.Substring(directory.FullPath.Length), key);
            }
        }
Exemple #3
0
        public void Decode(File file)
        {
            var aes = new AesEncryptor();

            aes.Decode(file.FullPath, GetDestinationFilePath(System.IO.Path.GetExtension(file.FullPath)), GetKeyFromDialog());
        }