High-performance streaming hash library for .NET 10. All 70 algorithms fully accessible including MurmurHash3, CityHash, SpookyHash, SipHash, FarmHash, HighwayHash, MetroHash, KangarooTwelve, wyhash, xxHash, plus complete cryptographic suite (SHA-3, BLAKE, Keccak, RIPEMD, Whirlpool, Tiger, GOST, Streebog, Skein, SM3, Grøstl, JH). Features unified HashFacade API with batch streaming support for parallel multi-algorithm processing. NEW: CreateBasicHashesStreaming() for common CRC32/MD5/SHA-1/SHA-256 use case. Comprehensive test coverage (788+ tests). SIMD-optimized implementations for HighwayHash64 (AVX2), Grøstl (AES-NI), JH (SSSE3), and custom high-performance Whirlpool.
$ dotnet add package StreamHashStreamHash 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 70 algorithms - all fully implemented and accessible.
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 ~16MB of memory regardless of file size.
Update() and Finalize()Span<T>HashFacade provides access to all 70 algorithms through a single interfaceCreateAllStreaming()| 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 |
The HashFacade class provides one-shot and streaming access to all 70 algorithms:
CRC32, CRC32C, CRC64, CRC-16-CCITT, CRC-16-MODBUS, CRC-16-USB, Adler-32, Fletcher-16, Fletcher-32
xxHash32/64/3/128, MurmurHash3-32/128, CityHash64/128, FarmHash64, SpookyHash128, SipHash-2-4, HighwayHash64, MetroHash64/128, wyhash64, FNV-1a (32/64), DJB2, DJB2a, SDBM, Lose Lose
MD2, MD4, MD5
SHA-0, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256
SHA3-224, SHA3-256, SHA3-384, SHA3-512, Keccak-256, Keccak-512
BLAKE-256, BLAKE-512, BLAKE2b, BLAKE2s, BLAKE3
RIPEMD-128, RIPEMD-160, RIPEMD-256, RIPEMD-320
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
dotnet add package StreamHash --version 1.8.0
Hash files with all 70 algorithms in parallel - perfect for file verification tools:
using StreamHash.Core;
// Create batch hasher for all 70 algorithms
using var multi = HashFacade.CreateAllStreaming();
// Stream file through all hashers in parallel
using var stream = File.OpenRead("large-file.bin");
byte[] buffer = new byte[16 * 1024 * 1024]; // 16MB buffer recommended
int read;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {
multi.Update(buffer.AsSpan(0, read));
}
// Get all 70 hashes as hex strings
Dictionary<string, string> results = multi.FinalizeAll();
// results["SHA256"] = "abc123..."
// results["MD5"] = "def456..."
// ... all 70 algorithms
Performance: 34MB file with 70 algorithms: ~12 seconds (~2.8 MB/s effective throughput)
For the common use case of verifying files with standard hashes (CRC32, MD5, SHA-1, SHA-256):
using StreamHash.Core;
// Hash a file with the 4 most common algorithms
using var basicHasher = HashFacade.CreateBasicHashesStreaming();
using var stream = File.OpenRead("download.zip");
var buffer = new byte[16 * 1024 * 1024]; // 16MB buffer
int bytesRead;
while ((bytesRead = stream.Read(buffer)) > 0) {
basicHasher.Update(buffer.AsSpan(0, bytesRead));
}
var results = basicHasher.FinalizeAll();
// Use constants instead of magic strings!
Console.WriteLine($"CRC32: {results[HashAlgorithmNames.Crc32]}");
Console.WriteLine($"MD5: {results[HashAlgorithmNames.Md5]}");
Console.WriteLine($"SHA-1: {results[HashAlgorithmNames.Sha1]}");
Console.WriteLine($"SHA-256: {results[HashAlgorithmNames.Sha256]}");
Performance: ~17.5x faster than computing all 70 algorithms when you only need these 4.
Tip: Use HashAlgorithmNames constants instead of string literals to avoid typos and enable refactoring!
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}");
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()}");
# Clone the repository
git clone https://github.com/TheAnsarya/StreamHash.git
cd StreamHash
# Build
dotnet build StreamHash.sln
# Run tests (752+ tests)
dotnet test
# Run benchmarks
dotnet run -c Release --project benchmarks/StreamHash.Benchmarks
Performance on Intel i7-8700K (Coffee Lake), .NET 10.0.2, Windows 10:
| Algorithm | Time | Throughput |
|---|---|---|
| CRC32 | 36 µs | 27.8 GB/s |
| XxHash3 | 43 µs | 23.3 GB/s |
| XxHash128 | 51 µs | 19.6 GB/s |
| XxHash64 | 83 µs | 12.0 GB/s |
| Wyhash64 | 130 µs | 7.7 GB/s |
| CityHash128 | 133 µs | 7.5 GB/s |
| FarmHash64 | 160 µs | 6.3 GB/s |
| CityHash64 | 199 µs | 5.0 GB/s |
| MurmurHash3_128 | 257 µs | 3.9 GB/s |
| SpookyHash128 | 341 µs | 2.9 GB/s |
| MurmurHash3_32 | 545 µs | 1.8 GB/s |
| HighwayHash64 | 756 µs | 1.4 GB/s (AVX2 SIMD in v1.6.2) |
| Algorithm | Time | Notes |
|---|---|---|
| Tiger-192 | 2.19 ms | Fast crypto |
| SHA-1 | 1.48 ms | Legacy |
| MD5 | 1.63 ms | Legacy |
| SHA-512 | 2.15 ms | 64-bit optimized |
| SHA3-256 | 3.18 ms | Keccak-based |
| SHA-256 | 3.67 ms | Standard |
| SM3 | 5.43 ms | Chinese standard |
| SHA3-512 | 6.22 ms | Keccak-based |
| Blake2b | 6.52 ms | Modern |
| Blake3 | 8.49 ms | Parallelizable |
| Whirlpool | 16.5 ms | Custom T-tables (3.2x faster in v1.6.2) |
| Grøstl-256 | 61 ms | AES-NI + T-tables (~2.5x faster in v1.6.2) |
| JH-256 | 137 ms | Bit-sliced + SSSE3 (~1.4x faster in v1.6.2) |
Whirlpool, Grøstl, and JH significantly optimized with custom implementations, SIMD, and T-tables in v1.6.2
Contributions are welcome! Please read our Contributing Guide for details.
This project is released into the public domain under The Unlicense. Do whatever you want with it.
StreamHash leverages several excellent libraries for cryptographic and high-performance hash implementations.
Blake3 - Native SIMD Rust wrapper for BLAKE3, 10-20x faster than pure C#.
Algorithms from Blake3.NET (1):
SauceControl.Blake2Fast - Fastest RFC 7693 BLAKE2 implementation for .NET with SSE2-AVX512 SIMD support.
Algorithms from Blake2Fast (4):
nebulae.dotSHA3 - XKCP-based native SHA-3 implementation with AVX2/NEON acceleration.
Algorithms from dotSHA3 (4):
acryptohashnet - Pure managed C# implementations with low memory footprint, compatible with System.Security.Cryptography.HashAlgorithm.
Algorithms from acryptohashnet (5):
BouncyCastle.Cryptography - Comprehensive cryptographic library (v2.6.2).
Algorithms from BouncyCastle (12):
Links:
Custom optimized implementations built into StreamHash:
Giving Back: If our performance optimizations prove successful and stable, we plan to contribute them back to the upstream projects. Open source thrives when we all give back! 🌱