예제 #1
0
        public void Test_Flush_FlushesHeader()
        {
            using (var outputStream = new MemoryStream())
                using (var key = XChaChaKey.Generate())
                    using (var encryptionStream = new XChaChaStream(outputStream, key, EncryptionMode.Encrypt))
                    {
                        var plaintext = Array.Empty <byte>();

                        encryptionStream.WriteFinal(plaintext);
                        encryptionStream.Flush();

                        var ciphertext = outputStream.ToArray();
                        Assert.Equal(StreamHeaderLength, ciphertext.Length);
                    }
        }