protected override async Task <byte[]> ComputeHashAsyncInternal(IUnifiedDataAsync data, CancellationToken cancellationToken) { var dataArray = await data.ToArrayAsync(cancellationToken) .ConfigureAwait(false); return(BitConverter.GetBytes( ComputeHashFromArray(dataArray))); }
/// <exception cref="System.InvalidOperationException">HashSize set to an invalid value.</exception> /// <inheritdoc /> protected override async Task <byte[]> ComputeHashAsyncInternal(IUnifiedDataAsync data, CancellationToken cancellationToken) { byte[] hash = null; var dataArray = await data.ToArrayAsync(cancellationToken) .ConfigureAwait(false); switch (_config.HashSizeInBits) { case 32: hash = BitConverter.GetBytes( ComputeHash32(dataArray)); break; case 64: hash = BitConverter.GetBytes( ComputeHash64(dataArray)); break; case 128: var result = ComputeHash128(dataArray); hash = new byte[16]; BitConverter.GetBytes(result.Low) .CopyTo(hash, 0); BitConverter.GetBytes(result.High) .CopyTo(hash, 8); break; default: throw new NotImplementedException(); } return(hash); }