StreamHash 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package StreamHash --version 1.3.0
                    
NuGet\Install-Package StreamHash -Version 1.3.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.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StreamHash" Version="1.3.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.3.0
                    
#r "nuget: StreamHash, 1.3.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.3.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.3.0
                    
Install as a Cake Addin
#tool nuget:?package=StreamHash&version=1.3.0
                    
Install as a Cake Tool

StreamHash

License: Unlicense .NET NuGet

StreamHash is a high-performance, memory-efficient streaming hash library for .NET 10+. It provides incremental/streaming implementations of popular hash algorithms and a unified HashFacade API supporting 62 algorithms.

๐ŸŽฏ 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 where available
  • ๐Ÿ”„ Streaming API: Process data incrementally with Update() and Finalize()
  • ๐Ÿ“ฆ Zero Allocations: Hot paths are allocation-free using Span<T>
  • ๐ŸŽฏ Unified API: HashFacade provides access to 62 algorithms through a single interface
  • ๐Ÿงช Thoroughly Tested: 619+ tests validating against official test vectors
  • ๐Ÿ“– Fully Documented: XML docs, examples, and algorithm references

๐Ÿ“Š Algorithm Support

Streaming Implementations (16 native)

Algorithm Digest Size Status
MurmurHash3-32/128 32/128-bit โœ… Complete
CityHash64/128 64/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/128 64/128-bit โœ… Complete
wyhash64 64-bit โœ… Complete
xxHash32/64/3/128* 32-128 bit โœ… Complete

HashFacade Unified API (62 algorithms)

The HashFacade class provides one-shot and streaming access to:

  • Checksums (6): CRC32, CRC32C, CRC64, Adler-32, Fletcher-16, Fletcher-32
  • Fast Non-Crypto (16): xxHash, MurmurHash3, CityHash, FarmHash, SpookyHash, SipHash, HighwayHash, MetroHash, wyhash
  • Cryptographic (26): MD family, SHA family, SHA-3, Keccak, BLAKE family, RIPEMD family
  • Other (14): Whirlpool, Tiger, GOST, Streebog, Skein, SM3

Note: Cryptographic algorithms (SHA-3, BLAKE, etc.) require BouncyCastle. StreamHash.Core provides fast non-crypto hashes natively.

๐Ÿš€ Quick Start

Installation

dotnet add package StreamHash --version 1.3.0
using StreamHash.Core;

// One-shot hashing
byte[] data = File.ReadAllBytes("file.bin");
byte[] hash = HashFacade.ComputeHash(HashAlgorithm.XxHash64, data);
string hex = HashFacade.ComputeHashHex(HashAlgorithm.Sha256, data);

// Streaming hashing
using var hasher = HashFacade.CreateStreaming(HashAlgorithm.MurmurHash3_128);
hasher.Update(chunk1);
hasher.Update(chunk2);
byte[] result = hasher.FinalizeBytes();

// Algorithm info
var info = HashFacade.GetInfo(HashAlgorithm.Sha256);
Console.WriteLine($"{info.DisplayName}: {info.DigestSize} bytes, Crypto: {info.IsCryptographic}");

Direct Streaming API

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));
}

UInt128 hash = hasher.Finalize();
Console.WriteLine($"Hash: {hasher.FinalizeHex()}");

๐Ÿ“– Documentation

๐Ÿ—๏ธ Building

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

# Build
dotnet build StreamHash.sln

# Run tests (619+ 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 747 2/10/2026
1.8.0 95 2/5/2026
1.7.0 88 2/5/2026
1.6.3 84 2/4/2026
1.6.2 86 2/4/2026
1.6.1 84 2/4/2026
1.6.0 86 2/4/2026
1.3.0 84 2/4/2026
1.2.0 86 2/4/2026

v1.3.0: Added unified HashFacade API with 62 algorithm support (checksums, fast hashes, crypto). IStreamingHashBytes interface for consistent byte[] output. 619 tests.