Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FlushFinalBlockAsync() [1/2]

async ValueTask System.Security.Cryptography.CryptoStream.FlushFinalBlockAsync ( bool useAsync,
CancellationToken cancellationToken )
inlineprivate

Definition at line 129 of file CryptoStream.cs.

130 {
132 {
133 throw new NotSupportedException(System.SR.Cryptography_CryptoStream_FlushFinalBlockTwice);
134 }
136 if (_canWrite)
137 {
139 if (useAsync)
140 {
141 await _stream.WriteAsync(new ReadOnlyMemory<byte>(array), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
142 }
143 else
144 {
145 _stream.Write(array, 0, array.Length);
146 }
147 }
148 if (_stream is CryptoStream cryptoStream)
149 {
150 if (!cryptoStream.HasFlushedFinalBlock)
151 {
152 await cryptoStream.FlushFinalBlockAsync(useAsync, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
153 }
154 }
155 else if (useAsync)
156 {
157 await _stream.FlushAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
158 }
159 else
160 {
161 _stream.Flush();
162 }
163 if (_inputBuffer != null)
164 {
165 Array.Clear(_inputBuffer);
166 }
167 if (_outputBuffer != null)
168 {
169 Array.Clear(_outputBuffer);
170 }
171 }
Task FlushAsync()
Definition Stream.cs:669
Task WriteAsync(byte[] buffer, int offset, int count)
Definition Stream.cs:914
void Write(byte[] buffer, int offset, int count)
static string Cryptography_CryptoStream_FlushFinalBlockTwice
Definition SR.cs:32
Definition SR.cs:7
readonly ICryptoTransform _transform
CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)

References System.Security.Cryptography.CryptoStream._canWrite, System.Security.Cryptography.CryptoStream._finalBlockTransformed, System.Security.Cryptography.CryptoStream._inputBuffer, System.Security.Cryptography.CryptoStream._inputBufferIndex, System.Security.Cryptography.CryptoStream._outputBuffer, System.Security.Cryptography.CryptoStream._stream, System.Security.Cryptography.CryptoStream._transform, System.array, System.cancellationToken, System.Array.Clear(), System.Threading.Tasks.Task< TResult >.ConfigureAwait(), System.SR.Cryptography_CryptoStream_FlushFinalBlockTwice, System.IO.Stream.Flush(), System.IO.Stream.FlushAsync(), System.Security.Cryptography.ICryptoTransform.TransformFinalBlock(), System.IO.Stream.Write(), and System.IO.Stream.WriteAsync().