Soenneker.Hashing.Sha256
4.0.1
Prefix Reserved
dotnet add package Soenneker.Hashing.Sha256 --version 4.0.1
NuGet\Install-Package Soenneker.Hashing.Sha256 -Version 4.0.1
<PackageReference Include="Soenneker.Hashing.Sha256" Version="4.0.1" />
<PackageVersion Include="Soenneker.Hashing.Sha256" Version="4.0.1" />
<PackageReference Include="Soenneker.Hashing.Sha256" />
paket add Soenneker.Hashing.Sha256 --version 4.0.1
#r "nuget: Soenneker.Hashing.Sha256, 4.0.1"
#:package Soenneker.Hashing.Sha256@4.0.1
#addin nuget:?package=Soenneker.Hashing.Sha256&version=4.0.1
#tool nuget:?package=Soenneker.Hashing.Sha256&version=4.0.1
Soenneker.Hashing.Sha256
Fast, dependency-light SHA-256 hashing and constant-time verification for bytes, UTF-8 text, streams, and files.
Results returned as text are canonical 64-character lowercase hexadecimal strings. Hexadecimal verification accepts either casing.
SHA-256 is designed for content integrity, fingerprints, and deterministic identifiers. It is not suitable for password storage; use a password-hashing algorithm such as Argon2id, bcrypt, or PBKDF2 instead.
Installation
dotnet add package Soenneker.Hashing.Sha256
Registration
services.AddSha256HashingUtilAsSingleton();
Scoped registration is also available through AddSha256HashingUtilAsScoped().
Text and bytes
ISha256HashingUtil sha256 = serviceProvider.GetRequiredService<ISha256HashingUtil>();
string textHash = sha256.Hash("hello world");
string bytesHash = sha256.HashToString("hello world"u8);
Span<byte> digest = stackalloc byte[32];
sha256.TryHash("hello world"u8, digest, out int bytesWritten);
Text is always encoded as UTF-8 without a byte-order mark.
Verification
string expected = "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9";
bool matches = sha256.Verify("hello world", expected);
Digest comparison uses CryptographicOperations.FixedTimeEquals.
Streams and files
string fileHash = await sha256.HashFile("archive.zip", cancellationToken);
bool fileMatches = await sha256.VerifyFile("archive.zip", expectedHash, cancellationToken);
await using Stream stream = File.OpenRead("archive.zip");
byte[] digest = await sha256.Hash(stream, cancellationToken);
Stream hashing begins at the stream's current position and consumes it through the end. Streams supplied by the caller are not disposed.
| 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
NuGet packages (12)
Showing the top 5 NuGet packages that depend on Soenneker.Hashing.Sha256:
| Package | Downloads |
|---|---|
|
Soenneker.Extensions.Spans.Readonly.Bytes
A collection of helpful ReadOnlySpan (byte) extension methods |
|
|
Soenneker.Cosmos.Client
A utility library for Azure Cosmos client accessibility |
|
|
Soenneker.Cosmos.Database
A utility library for storing Azure Cosmos databases |
|
|
Soenneker.Cosmos.Container
A utility library for storing Azure Cosmos containers |
|
|
Soenneker.Cloudflare.HttpClient
An async thread-safe HttpClient singleton for the Cloudflare API |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1 | 15,704 | 9/4/2026 |