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

◆ ComputeHashAsyncCore()

async Task< byte[]> System.Security.Cryptography.HashAlgorithm.ComputeHashAsyncCore ( Stream inputStream,
CancellationToken cancellationToken )
inlineprivateinherited

Definition at line 153 of file HashAlgorithm.cs.

154 {
155 byte[] rented = ArrayPool<byte>.Shared.Rent(4096);
156 Memory<byte> buffer = rented;
157 int clearLimit = 0;
158 int num;
159 while ((num = await inputStream.ReadAsync(buffer, cancellationToken).ConfigureAwait(continueOnCapturedContext: false)) > 0)
160 {
161 if (num > clearLimit)
162 {
163 clearLimit = num;
164 }
165 HashCore(rented, 0, num);
166 }
167 CryptographicOperations.ZeroMemory(rented.AsSpan(0, clearLimit));
168 ArrayPool<byte>.Shared.Return(rented);
170 }
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
Task< int > ReadAsync(byte[] buffer, int offset, int count)
Definition Stream.cs:762
void HashCore(byte[] array, int ibStart, int cbSize)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226

References System.buffer, System.cancellationToken, System.Security.Cryptography.HashAlgorithm.CaptureHashCodeAndReinitialize(), System.Threading.Tasks.Task< TResult >.ConfigureAwait(), System.Security.Cryptography.HashAlgorithm.HashCore(), System.IO.Stream.ReadAsync(), System.Buffers.ArrayPool< T >.Shared, and System.Security.Cryptography.CryptographicOperations.ZeroMemory().

Referenced by System.Security.Cryptography.HashAlgorithm.ComputeHashAsync().