public async Task TestMethod1()
        {
            // Arrange
            var inMemoryFileSystem = new InMemoryFileSystem();
            var inMemoryRoot       = await inMemoryFileSystem.GetOrCreateDirectoryItemAsync("", CancellationToken.None);

            var aesProvider = new AesFileSystem(inMemoryFileSystem);

            aesProvider.Version  = AesVersion.Aes128;
            aesProvider.Password = "******";

            var aesRoot = await aesProvider.GetOrCreateDirectoryItemAsync("", CancellationToken.None);

            // Act
            var encryptedFile = await aesRoot.CreateFileAsync("encrypted.png", new byte[] { 1, 2 }, CancellationToken.None);

            await inMemoryRoot.CopyFileAsync(encryptedFile, "decrypted.png", CancellationToken.None);

            var rawFile          = inMemoryFileSystem.GetFile("encrypted.png");
            var rawEncryptedFile = await inMemoryRoot.CopyFileAsync(rawFile, "encrypted.png", CancellationToken.None);

            var rawDecryptedFile = await inMemoryRoot.CopyFileAsync(encryptedFile, "decrypted.png", CancellationToken.None);

            // Assert
            var rawDecryptedFileContent = await rawDecryptedFile.GetContentBytesAsync(CancellationToken.None);

            var rawEncryptedFileContent = await rawEncryptedFile.GetContentBytesAsync(CancellationToken.None);

            Assert.AreEqual(33, rawEncryptedFileContent.Length);
            Assert.AreEqual(2, rawDecryptedFileContent.Length);
            CollectionAssert.AreEquivalent(new byte[] { 1, 2 }, rawDecryptedFileContent);
        }
        private static IFileSystem CreateAesFileSystem(IFileSystem fileSystem, CommandOption method, CommandOption password, CommandOption passwordName, CommandOption askPassword, CommandOption encryptFileNames, CommandOption encryptDirectoryNames)
        {
            if (!password.HasValue() && !askPassword.HasValue() && !passwordName.HasValue())
            {
                return(fileSystem);
            }

            string applicationName = null;
            string pwd             = GetValue(password, (string)null);

            if (string.IsNullOrEmpty(pwd))
            {
                applicationName = GetValue(passwordName, null);
                if (!string.IsNullOrEmpty(applicationName))
                {
                    var cred = CredentialManager.ReadCredential(applicationName);
                    if (cred != null)
                    {
                        pwd = cred.Password;
                    }
                }
            }

            if (string.IsNullOrEmpty(pwd) && GetValue(askPassword, false))
            {
                System.Console.Write("Enter password: "******"", pwd, CredentialPersistence.LocalMachine);
                }
            }

            if (string.IsNullOrEmpty(pwd))
            {
                return(null);
            }

            var aesFs = new AesFileSystem(fileSystem);

            aesFs.Version = GetValue(method, AesVersion.Aes256);
            aesFs.EncryptDirectoryName = GetValue(encryptDirectoryNames, false);
            aesFs.EncryptFileName      = GetValue(encryptFileNames, false);
            aesFs.Password             = pwd;
            return(aesFs);
        }