public void WriterReaderVaultHeader() { const string targetPath = Preparations.TestFolderPath + "WriterReaderVaultHeader.td"; var key = CryptoRNG.GetRandomBytes(AesSizes.Key); var header = VaultHeader.Create(); using (var stream = new FileStream(targetPath, FileMode.Create, FileAccess.Write)) { var writer = new VaultHeaderWriter(header); writer.WriteTo(stream, key); } VaultHeader readHeader; using (var stream = new FileStream(targetPath, FileMode.Open, FileAccess.Read)) { readHeader = VaultHeaderReader.ReadFrom(stream); } Assert.IsTrue(readHeader.MasterPassword.GetDecryptedPassword(key).Item1); }
private static void WriteHeader(Stream fileStream, Vault underlying, byte[] key) { var headerWriter = new VaultHeaderWriter(underlying.Header); headerWriter.WriteTo(fileStream, key); }