Soenneker.Hashing.Blake3 4.0.25

Prefix Reserved
dotnet add package Soenneker.Hashing.Blake3 --version 4.0.25
                    
NuGet\Install-Package Soenneker.Hashing.Blake3 -Version 4.0.25
                    
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="Soenneker.Hashing.Blake3" Version="4.0.25" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Hashing.Blake3" Version="4.0.25" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Hashing.Blake3" />
                    
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 Soenneker.Hashing.Blake3 --version 4.0.25
                    
#r "nuget: Soenneker.Hashing.Blake3, 4.0.25"
                    
#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 Soenneker.Hashing.Blake3@4.0.25
                    
#: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=Soenneker.Hashing.Blake3&version=4.0.25
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Hashing.Blake3&version=4.0.25
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Hashing.Blake3

A high-performance .NET library for BLAKE3 hashing and constant-time verification. Pure C# with optional SIMD acceleration (AVX2 on x64, NEON on ARM).

Features

  • BLAKE3 — 256-bit cryptographic hash; fast, secure, and specified in the official BLAKE3 spec.
  • Zero dependencies — only the .NET runtime; no native or third-party packages.
  • SIMD — uses AVX2 (x64) and NEON (ARM) when available for faster chunk hashing.
  • Parallel hashingHashParallel for large inputs; multi-threaded with batched SIMD where applicable.
  • Span/Memory-friendly — hashing from byte[], ReadOnlySpan<byte>, ReadOnlyMemory<byte>, and in-place digest writing.
  • Strings — hash UTF-8 strings and get hex output via Hash(string) and HashToString(string).
  • Constant-time verificationVerify uses CryptographicOperations.FixedTimeEquals for digest comparison.
  • Blake3Util — optional DI-registered utility for file and directory hashing (hash single files, whole directories, or an aggregate hash of a directory).

Installation

dotnet add package Soenneker.Hashing.Blake3

Quick Start

using Soenneker.Hashing.Blake3;

// Hash bytes → 32-byte digest
byte[] data = System.Text.Encoding.UTF8.GetBytes("hello world");
byte[] hash = Blake3Hasher.Hash(data);

// Hash string (UTF-8) → hex
string hex = Blake3Hasher.HashToString("hello world");
// e.g. "d74981efa70a0c0b14d123f472c6e570..."

// Verify digest (constant-time)
bool ok = Blake3Hasher.Verify(data, hash);

Usage

Hashing

Method Description
Hash(byte[] input) Hash and return a new 32-byte array.
Hash(ReadOnlySpan<byte> input) Hash from span; returns 32-byte array.
Hash(ReadOnlyMemory<byte> input) Hash from memory; returns 32-byte array.
Hash(..., Span<byte> destination) Hash and write digest into destination (must be ≥ 32 bytes).
Hash(string s) Hash UTF-8 bytes of the string; returns 32-byte array.
Hash(ReadOnlySpan<char> chars) Hash UTF-8 encoding of the character span.
HashToString(string input) Hash string (UTF-8) and return 64-character lowercase hex.

Single-chunk and multi-chunk inputs use a scalar path; no extra allocations for the common case.

Parallel hashing (large inputs)

For large buffers, use the parallel API to spread work across cores and use SIMD batches where supported:

Method Description
HashParallel(byte[] input) Hash with parallel chunk processing; returns 32-byte array.
HashParallel(ReadOnlyMemory<byte> input) Same, from ReadOnlyMemory<byte>.
HashParallel(..., Span<byte> destination) Parallel hash into destination (≥ 32 bytes).
HashParallelCopy(ReadOnlySpan<byte> input) Copies input then runs parallel hash (use when you only have a span of a large buffer).

Parallelism kicks in when the input is large enough to form multiple chunks (e.g. > 4 KiB). For smaller inputs, the regular Hash methods are usually faster.

Blake3Util (file and directory hashing)

For file-based workflows, register Blake3Util (e.g. via Blake3UtilRegistrar) and inject IBlake3Util. It can hash individual files, entire directories, or produce a single aggregate hash for a directory (useful for integrity checks of a folder’s contents).

Method Description
HashFile(path) Hash a file and return its BLAKE3 digest as a 64-character hex string.
HashFileToByteArray(path) Hash a file and return the 32-byte digest.
HashDirectory(path) Hash every file in a directory (recursive); returns a dictionary of file path → 32-byte digest.
HashDirectoryToAggregateString(path) Hash all files in a directory (sorted by path), combine path + hash per file, then BLAKE3 the aggregate; returns a single 64-character hex string for the whole directory.

All methods are async and accept an optional CancellationToken. Files that cannot be read (e.g. access denied) are skipped when hashing directories.

Verification

All Verify overloads compare the computed BLAKE3 digest to an expected value in constant time (via CryptographicOperations.FixedTimeEquals). The expected digest must be 32 bytes (or 64 hex characters where applicable).

Method Description
Verify(ReadOnlySpan<byte> input, ReadOnlySpan<byte> expectedHash) Returns true if BLAKE3(input) equals expectedHash (32 bytes).
Verify(byte[] input, byte[] expectedHash) Same for byte arrays.
Verify(string input, ReadOnlySpan<byte> expectedHash) Hash UTF-8 string and compare to 32-byte digest.
Verify(string input, string expectedHashHex) Hash UTF-8 string and compare to 64-char hex string (case-insensitive).

Output

  • Digest length is 32 bytes (256 bits), as per BLAKE3.
  • Hex strings from HashToString are 64 lowercase hex characters.
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 (1)

Showing the top 1 NuGet packages that depend on Soenneker.Hashing.Blake3:

Package Downloads
Soenneker.Managers.HashChecking

Handles hashing and verification of binaries

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.25 0 3/13/2026
4.0.24 19 3/12/2026
4.0.23 28 3/12/2026
4.0.21 300 3/12/2026
4.0.20 548 3/11/2026
4.0.19 43 3/11/2026
4.0.18 974 3/11/2026
4.0.17 35 3/11/2026
4.0.16 48 3/11/2026
4.0.15 1,051 3/10/2026
4.0.13 1,362 3/9/2026
4.0.12 88 3/9/2026
4.0.11 75 3/9/2026
4.0.10 1,748 3/7/2026
4.0.9 201 3/7/2026
4.0.8 932 3/5/2026
4.0.7 304 3/5/2026
4.0.6 97 3/5/2026
4.0.5 796 3/4/2026
4.0.4 573 3/4/2026
Loading failed

Update dependency Soenneker.Utils.File to 4.0.2127 (#48)

Automatically merged