From the Microsoft .NET API the following information can be extracted:
usingwill call the implementation ofIDisposable.Dispose();IDisposable.Dispose()should callFlush()on anyStreaminstance;CryptoStream.Close()will callCryptoStream.FlushFinalBlock().
However, this seems to leave a gap in the specification: will disposing of a CryptoStream instance also call CryptoStream.FlushFinalBlock(), and if so, where is this documented?
Dispose()callsFlushFinalBlock()if it has not already been called. This is also in the documentation, however not centrally, but distributed:CryptoStreamsdoes not overloadClose()or the (parameterless) publicDispose(), so the implementations of theStreamclass are called.The documentation of
Stream#Dispose()(s. Remarks) states:This is consistent with the source code (from .NET Framework 4.8).
Stream#Dispose()callsStream#Close().The documentation of
CryptoStream#FlushFinalBlock()(s. Remarks) says (as already described by you):This is again consistent with the source code (from .NET Framework 4.8).
Close()calls (among other things) the protected (virtual) overloadDispose(true), which is overridden inCryptoStream, seeCryptoStream#Dispose(bool disposing), and which callsFlushFinalBlock()if it has not already been called (i.e. depending on_finalBlockTransformed),These details are described in
CryptoStream#Dispose(Boolean)(s. Remarks):