StreamHash 1.6.0
See the version list below for details.
dotnet add package StreamHash --version 1.6.0
NuGet\Install-Package StreamHash -Version 1.6.0
<PackageReference Include="StreamHash" Version="1.6.0" />
<PackageVersion Include="StreamHash" Version="1.6.0" />
<PackageReference Include="StreamHash" />
paket add StreamHash --version 1.6.0
#r "nuget: StreamHash, 1.6.0"
#:package StreamHash@1.6.0
#addin nuget:?package=StreamHash&version=1.6.0
#tool nuget:?package=StreamHash&version=1.6.0
StreamHash
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 - all fully implemented and accessible.
π― 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()andFinalize() - π¦ Zero Allocations: Hot paths are allocation-free using
Span<T> - π― Unified API:
HashFacadeprovides access to all 62 algorithms through a single interface - π Full Crypto Support: All cryptographic algorithms via BouncyCastle integration
- π§ͺ Thoroughly Tested: 646+ tests validating against official test vectors
- π Fully Documented: XML docs, examples, and algorithm references
π Algorithm Support (All 62 Fully Implemented!)
Native Streaming Implementations (16)
| 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 all 62 algorithms:
Checksums (6)
CRC32, CRC32C, CRC64, Adler-32, Fletcher-16, Fletcher-32
Fast Non-Crypto (16)
xxHash32/64/3/128, MurmurHash3-32/128, CityHash64/128, FarmHash64, SpookyHash128, SipHash-2-4, HighwayHash64, MetroHash64/128, wyhash64
MD Family (3)
MD2, MD4, MD5
SHA-1/2 Family (9)
SHA-0, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256
SHA-3 & Keccak (6)
SHA3-224, SHA3-256, SHA3-384, SHA3-512, Keccak-256, Keccak-512
BLAKE Family (5)
BLAKE-256, BLAKE-512, BLAKE2b, BLAKE2s, BLAKE3
RIPEMD Family (4)
RIPEMD-128, RIPEMD-160, RIPEMD-256, RIPEMD-320
Other Cryptographic (14)
Whirlpool, Tiger-192, GOST R 34.11-94, Streebog-256, Streebog-512, Skein-256, Skein-512, Skein-1024, GrΓΈstl-256, GrΓΈstl-512, JH-256, JH-512, KangarooTwelve, SM3
π Quick Start
Installation
dotnet add package StreamHash --version 1.4.0
HashFacade API (Recommended)
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 (646+ 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
- SMHasher - MurmurHash reference implementation
- CityHash - Google's CityHash
- SpookyHash - Bob Jenkins' SpookyHash
- SipHash - Reference SipHash implementation
| Product | Versions 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. |
-
net10.0
- BouncyCastle.Cryptography (>= 2.5.1)
- System.IO.Hashing (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.6.0: Comprehensive XML documentation overhaul. Added SIMD feature detection (AVX2/SSE4.1) to all streaming hash implementations. Detailed algorithm explanations with step-by-step inline comments for: MurmurHash3 (32/128), CityHash (64/128), FarmHash64, SpookyHash128, SipHash24, HighwayHash64, MetroHash (64/128), wyhash64, and xxHash (32/64/3/128). 678 tests passing. All APIs now fully documented.