<PackageReference Include="Azure.Storage.Blobs" Version="12.24.1" />

NonCryptographicHashAlgorithmHasher

HashAlgorithm wrapper for IHasher interface.
using System; using System.IO; using System.IO.Hashing; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace Azure.Storage { internal class NonCryptographicHashAlgorithmHasher : IHasher, IDisposable { private const int _streamBufferSize = 4194304; private readonly NonCryptographicHashAlgorithm _nonCryptographicHashAlgorithm; public int HashSizeInBytes => _nonCryptographicHashAlgorithm.get_HashLengthInBytes(); public NonCryptographicHashAlgorithmHasher(NonCryptographicHashAlgorithm nonCryptographicHashAlgorithm) { _nonCryptographicHashAlgorithm = nonCryptographicHashAlgorithm; } [AsyncStateMachine(typeof(<ComputeHashInternal>d__5))] public Task<byte[]> ComputeHashInternal(Stream stream, bool async, CancellationToken cancellationToken) { <ComputeHashInternal>d__5 stateMachine = default(<ComputeHashInternal>d__5); stateMachine.<>t__builder = AsyncTaskMethodBuilder<byte[]>.Create(); stateMachine.<>4__this = this; stateMachine.stream = stream; stateMachine.async = async; stateMachine.cancellationToken = cancellationToken; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } public void AppendHash(ReadOnlySpan<byte> content) { _nonCryptographicHashAlgorithm.Append(content); } public int GetFinalHash(Span<byte> hashDestination) { return _nonCryptographicHashAlgorithm.GetCurrentHash(hashDestination); } public void Dispose() { } } }