Blake3.Managed
1.2.1
See the version list below for details.
dotnet add package Blake3.Managed --version 1.2.1
NuGet\Install-Package Blake3.Managed -Version 1.2.1
<PackageReference Include="Blake3.Managed" Version="1.2.1" />
<PackageVersion Include="Blake3.Managed" Version="1.2.1" />
<PackageReference Include="Blake3.Managed" />
paket add Blake3.Managed --version 1.2.1
#r "nuget: Blake3.Managed, 1.2.1"
#:package Blake3.Managed@1.2.1
#addin nuget:?package=Blake3.Managed&version=1.2.1
#tool nuget:?package=Blake3.Managed&version=1.2.1
Blake3.Managed — BLAKE3 hash function for .NET
A pure managed C# implementation of the BLAKE3 cryptographic hash function for .NET. Uses hardware intrinsics (AVX2, SSE/SSSE3, ARM NEON) for high performance with automatic scalar fallback — faster than SHA-256 and MD5, with zero native dependencies and no P/Invoke.
BLAKE3 is a modern, secure hash ideal for file checksums, content addressing, deduplication, data integrity, message authentication (keyed MAC) and key derivation (KDF). This library brings it to C# / .NET as a single fully managed, Native AOT-friendly NuGet package that runs everywhere .NET runs.
Features
- Pure managed C# - no native libraries, no P/Invoke, runs everywhere .NET runs
- Hardware accelerated - AVX2 8-way parallel hashing, SSE/SSSE3 vectorized compression, ARM NEON 4-way parallel hashing, automatic scalar fallback
- Multi-threaded - uses the thread pool for parallel chunk processing on large inputs (>64 KiB)
- Zero allocation for small inputs - one-shot
Hasher.Hash()uses stack allocation - All BLAKE3 modes - default hashing, keyed hashing, and key derivation
- XOF support - extendable output with seekable byte stream
- API compatible - similar API to the Blake3 Rust API and mirrors Blake3.NET API surface
- Targets
net6.0,net8.0andnet10.0(with hardware intrinsics)
Blake3.Managed vs Blake3.NET (native wrapper)
Blake3.NET by Alexandre Mutel is a very polished BLAKE3 library for .NET - it wraps the official Rust implementation via P/Invoke. If native dependencies work for your project, it's an excellent choice.
This library exists for cases where a fully managed solution is preferred - easier deployment, no native binaries to ship, Native AOT and trimming friendliness, and support for platforms where the Rust library isn't available. My goal was to get as close to native performance as possible while staying pure C# - small inputs hash within ~5% of native, and one-shot hashing of large inputs (> 128 KB) is now faster than the native wrapper thanks to multithreaded subtree hashing (see benchmarks below). Some ideas and code examples are borrowed from Blake3.NET.
Installation
dotnet add package Blake3.Managed
Quick Start
using Blake3.Managed;
// One-shot hash
var hash = Hasher.Hash("Hello, World!"u8);
Console.WriteLine(hash); // 288a86a79f20a3d6dccdca1c47c4c4726cddf1ae8c3ae5bdddf8f57a76a3a02e
// Incremental hashing
using var hasher = Hasher.New();
hasher.Update("Hello, "u8);
hasher.Update("World!"u8);
var result = hasher.Finalize();
// Keyed hash (32-byte key)
byte[] key = new byte[32]; // your key here
using var keyedHasher = Hasher.NewKeyed(key);
keyedHasher.Update(data);
var mac = keyedHasher.Finalize();
// Key derivation
using var kdf = Hasher.NewDeriveKey("my-session-key");
kdf.Update(inputKeyMaterial);
var derivedKey = kdf.Finalize();
// Extended output (XOF)
using var xof = Hasher.New();
xof.Update(data);
var extendedOutput = new byte[1024];
xof.Finalize(extendedOutput); // arbitrary length output
// Parallel hashing for large data
using var parallel = Hasher.New();
parallel.UpdateWithJoin(largeData); // uses thread pool for inputs >= 64 KiB
var parallelHash = parallel.Finalize();
Public API
| Type | Description |
|---|---|
Hasher |
Main hasher struct. Factory methods: New(), NewKeyed(), NewDeriveKey(). Static Hash() for one-shot. Incremental via Update()/UpdateWithJoin()/Finalize(). |
Hash |
Fixed 32-byte output struct with constant-time equality and allocation-free ToString(). |
Blake3Stream |
Stream wrapper that hashes data as it flows through. |
Blake3HashAlgorithm |
System.Security.Cryptography.HashAlgorithm adapter for interop with existing APIs. |
Performance
Benchmarks
One-shot hashing (Hasher.Hash(data)) compared against Blake3.NET (native Rust P/Invoke) and System.Security.Cryptography.SHA256:
BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8457/25H2)
AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics 3.30GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK 10.0.300
[Host] : .NET 10.0.8 (10.0.826.23019), X64 RyuJIT x86-64-v4
| Method | Data Size | Mean | Ratio |
|---|---|---|---|
| Blake3 (native) | 4 B | 67.6 ns | 1.00 |
| Blake3.Managed | 4 B | 72.5 ns | 1.07 |
| Blake3.Managed (HashAlgo) | 4 B | 144.7 ns | 2.14 |
| SHA256 | 4 B | 131.3 ns | 1.94 |
| Blake3 (native) | 100 B | 119.7 ns | 1.00 |
| Blake3.Managed | 100 B | 124.0 ns | 1.04 |
| Blake3.Managed (HashAlgo) | 100 B | 228.4 ns | 1.91 |
| SHA256 | 100 B | 192.4 ns | 1.61 |
| Blake3 (native) | 1000 B | 840.4 ns | 1.00 |
| Blake3.Managed | 1000 B | 883.9 ns | 1.05 |
| SHA256 | 1000 B | 542.0 ns | 0.64 |
| Blake3 (native) | 10 KB | 2.83 us | 1.00 |
| Blake3.Managed | 10 KB | 3.76 us | 1.33 |
| SHA256 | 10 KB | 4.55 us | 1.61 |
| Blake3 (native) | 100 KB | 14.78 us | 1.00 |
| Blake3.Managed | 100 KB | 21.79 us | 1.47 |
| SHA256 | 100 KB | 43.87 us | 2.97 |
| Blake3 (native) | 1 MB | 142.6 us | 1.00 |
| Blake3.Managed | 1 MB | 60.2 us | 0.42 |
| SHA256 | 1 MB | 434.3 us | 3.05 |
- For small inputs (< 1 KB): Blake3.Managed is similar native Rust performance
- For medium inputs (10-100 KB): Blake3.Managed is ~1.3-1.5x slower than native
- For large inputs (> 128 KB): Blake3.Managed one-shot
Hash()is faster than native (2.4x at 1 MB), because it hashes 64-chunk subtrees in parallel on the thread pool while the native one-shot is single-threaded. Single-threadedUpdate()remains slower than native. - Take these results with a grain of salt, I don't have great benchmarking skills (PRs welcome)
Hardware Intrinsics Tiering
The implementation automatically selects the best available instruction set at runtime:
| Tier | Instructions | Parallelism |
|---|---|---|
| AVX2 | 256-bit vectors | 8 chunks simultaneously, plus 8-way parent-node hashing for the merge tree |
| SSE/SSSE3 | 128-bit vectors + shuffle | 4 chunks simultaneously, single-lane SIMD fallback |
| ARM NEON | 128-bit vectors | 4 chunks simultaneously |
| Scalar | Pure C# | Portable fallback |
Building from Source
# Requires .NET 10 SDK
dotnet build src -c Release
# Run tests
dotnet test src/Blake3.Managed.Tests -c Release
# Run benchmarks
dotnet run --project src/Blake3.Managed.Benchmarks -c Release
# Create NuGet package
dotnet pack src/Blake3.Managed -c Release
Acknowledgments
- Blake3.NET by Alexandre Mutel — API design and test infrastructure
- Blake2Fast by Clinton Ingram — shuffle-based SSE message permutation
- BLAKE3 Reference Implementation — algorithm specification and test vectors
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
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 | 37,790 | 10/14/2026 |
| 1.9.0 | 227 | 10/9/2026 |
| 1.8.0 | 2,268 | 9/24/2026 |
| 1.7.4 | 404 | 9/22/2026 |
| 1.7.3 | 125 | 9/21/2026 |
| 1.7.2 | 141 | 9/20/2026 |
| 1.7.1 | 130 | 9/20/2026 |
| 1.7.0 | 128 | 9/20/2026 |
| 1.6.0 | 231 | 9/14/2026 |
| 1.5.2 | 1,127 | 9/9/2026 |
| 1.5.1 | 251 | 9/4/2026 |
| 1.5.0 | 173 | 9/3/2026 |
| 1.4.0 | 237 | 9/2/2026 |
| 1.3.0 | 6,090 | 7/31/2026 |
| 1.2.1 | 3,083 | 6/10/2026 |
| 1.2.0 | 153 | 6/10/2026 |
| 1.1.0 | 819 | 2/27/2026 |
| 1.0.0 | 172 | 2/26/2026 |
| 0.1.0-rc.1 | 108 | 2/26/2026 |