StreamHash 1.6.2
See the version list below for details.
dotnet add package StreamHash --version 1.6.2
NuGet\Install-Package StreamHash -Version 1.6.2
<PackageReference Include="StreamHash" Version="1.6.2" />
<PackageVersion Include="StreamHash" Version="1.6.2" />
<PackageReference Include="StreamHash" />
paket add StreamHash --version 1.6.2
#r "nuget: StreamHash, 1.6.2"
#:package StreamHash@1.6.2
#addin nuget:?package=StreamHash&version=1.6.2
#tool nuget:?package=StreamHash&version=1.6.2
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 71 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 71 algorithms through a single interface - 🔐 Full Crypto Support: All cryptographic algorithms via BouncyCastle integration
- 🧪 Thoroughly Tested: 752+ tests validating against official test vectors
- 📖 Fully Documented: XML docs, examples, and algorithm references
📊 Algorithm Support (All 71 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 (71 algorithms)
The HashFacade class provides one-shot and streaming access to all 71 algorithms:
Checksums (9)
CRC32, CRC32C, CRC64, CRC-16-CCITT, CRC-16-MODBUS, CRC-16-USB, Adler-32, Fletcher-16, Fletcher-32
Fast Non-Crypto (22)
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
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.6.2
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 (752+ tests)
dotnet test
# Run benchmarks
dotnet run -c Release --project benchmarks/StreamHash.Benchmarks
📊 Benchmarks (v1.6.2)
Performance on Intel i7-8700K (Coffee Lake), .NET 10.0.2, Windows 10:
Fast Non-Crypto Hashes (1MB data)
| 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) |
Cryptographic Hashes (1MB data)
| 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
🤝 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.2: SIMD optimizations across the board. HighwayHash64: AVX2/SSE4.1 optimization (1.4x faster). Whirlpool: Custom T-table implementation (3.2x faster). Grøstl: AES-NI SubBytes + T-table MixBytes (~2.5x faster). JH: Bit-sliced S-box + SSSE3 (~1.4x faster). GitHub Actions CI/CD added. Memory allocations greatly reduced. All optimizations have scalar fallbacks. 752 tests passing. All 71 algorithms validated.