StreamHash 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package StreamHash --version 1.2.0
                    
NuGet\Install-Package StreamHash -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StreamHash" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StreamHash" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="StreamHash" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StreamHash --version 1.2.0
                    
#r "nuget: StreamHash, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StreamHash@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StreamHash&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=StreamHash&version=1.2.0
                    
Install as a Cake Tool

StreamHash

License: Unlicense .NET

StreamHash is a high-performance, memory-efficient streaming hash library for .NET 10+. It provides incremental/streaming implementations of popular non-cryptographic hash algorithms that traditionally require loading entire files into memory.

๐ŸŽฏ Why StreamHash?

Many popular hash algorithms (MurmurHash, CityHash, SpookyHash, etc.) don't have official streaming APIs. This means hashing a 10GB file requires 10GB of RAM! StreamHash solves this by providing streaming implementations that process data in chunks, using only ~1MB of memory regardless of file size.

โœจ Features

  • ๐Ÿš€ Memory Efficient: Hash multi-gigabyte files with minimal memory footprint
  • โšก High Performance: SIMD-optimized implementations (SSE2, AVX2, AVX-512)
  • ๐Ÿ”„ Streaming API: Process data incrementally with Update() and Finalize()
  • ๐Ÿ“ฆ Zero Allocations: Hot paths are allocation-free using Span<T>
  • ๐Ÿงช Thoroughly Tested: Validated against official test vectors
  • ๐Ÿ“– Fully Documented: XML docs, examples, and algorithm references

๐Ÿ“Š Supported Algorithms

Algorithm Digest Size Streaming SIMD Status
MurmurHash3-32 32-bit โœ… โŒ โœ… Complete
MurmurHash3-128 128-bit โœ… โŒ โœ… Complete
CityHash64 64-bit โœ… โŒ โœ… Complete
CityHash128 128-bit โœ… โŒ โœ… Complete
SpookyHash V2 128-bit โœ… โŒ โœ… Complete
SipHash-2-4 64-bit โœ… โŒ โœ… Complete
FarmHash64 64-bit โœ… โŒ โœ… Complete
HighwayHash64 64-bit โœ… ๐Ÿšง โœ… Complete
KangarooTwelve Variable (XOF) โœ… โŒ โœ… Complete
MetroHash64 64-bit โœ… โŒ โœ… Complete
MetroHash128 128-bit โœ… โŒ โœ… Complete
wyhash64 64-bit โœ… โŒ โœ… Complete
xxHash32* 32-bit โœ… โœ… โœ… Complete
xxHash64* 64-bit โœ… โœ… โœ… Complete
xxHash3* 64-bit โœ… โœ… โœ… Complete
xxHash128* 128-bit โœ… โœ… โœ… Complete

16 algorithms total with 532 tests!

* xxHash wrappers use System.IO.Hashing for IStreamingHash compatibility

๐Ÿš€ Quick Start

Installation

dotnet add package StreamHash --version 1.2.0

Basic Usage

using StreamHash.Core;

// Hash a file incrementally
using var hasher = new MurmurHash3_128();
using var stream = File.OpenRead("large-file.bin");

byte[] buffer = new byte[1024 * 1024]; // 1MB buffer
int bytesRead;

while ((bytesRead = await stream.ReadAsync(buffer)) > 0) {
    hasher.Update(buffer.AsSpan(0, bytesRead));
}

var hash = hasher.Finalize();
Console.WriteLine($"Hash: {Convert.ToHexStringLower(hash)}");

One-Shot API

// For small data that fits in memory
var hash = MurmurHash3.ComputeHash128(data);

๐Ÿ“– Documentation

๐Ÿ—๏ธ Building

# Clone the repository
git clone https://github.com/TheAnsarya/StreamHash.git
cd StreamHash

# Build
dotnet build StreamHash.sln

# Run tests
dotnet test

# Run benchmarks
dotnet run -c Release --project benchmarks/StreamHash.Benchmarks

๐Ÿ“Š Benchmarks

Benchmarks comparing StreamHash to reference implementations:

| Method              | File Size | Memory    | Throughput |
|---------------------|-----------|-----------|------------|
| MurmurHash3 (ref)   | 1 GB      | 1,024 MB  | 3.2 GB/s   |
| MurmurHash3 (stream)| 1 GB      | 1 MB      | 3.1 GB/s   |
| CityHash (ref)      | 1 GB      | 1,024 MB  | 4.5 GB/s   |
| CityHash (stream)   | 1 GB      | 1 MB      | 4.3 GB/s   |

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guide for details.

๐Ÿ“„ License

This project is released into the public domain under The Unlicense. Do whatever you want with it.

๐Ÿ™ Acknowledgments

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.10.0 748 2/10/2026
1.8.0 96 2/5/2026
1.7.0 89 2/5/2026
1.6.3 85 2/4/2026
1.6.2 87 2/4/2026
1.6.1 85 2/4/2026
1.6.0 87 2/4/2026
1.3.0 85 2/4/2026
1.2.0 87 2/4/2026

v1.2.0: Added wyhash64, xxHash (32/64/3/128) wrappers. 16 algorithms total, 532 tests.