diff --git a/LiteDB/Engine/Disk/Streams/AesStream.cs b/LiteDB/Engine/Disk/Streams/AesStream.cs index 9fd66df30..c21bfa571 100644 --- a/LiteDB/Engine/Disk/Streams/AesStream.cs +++ b/LiteDB/Engine/Disk/Streams/AesStream.cs @@ -103,6 +103,10 @@ public AesStream(string password, Stream stream) checkBuffer.Fill(1, 0, checkBuffer.Length); _writer.Write(checkBuffer, 0, checkBuffer.Length); + + //ensure that the "hidden" page in encrypted files is created correctly + _stream.Position = PAGE_SIZE - 1; + _stream.WriteByte(0); } else { @@ -115,6 +119,7 @@ public AesStream(string password, Stream stream) } _stream.Position = PAGE_SIZE; + _stream.FlushToDisk(); } catch