nebulae.dotSHA2 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package nebulae.dotSHA2 --version 0.1.1
                    
NuGet\Install-Package nebulae.dotSHA2 -Version 0.1.1
                    
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="nebulae.dotSHA2" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nebulae.dotSHA2" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="nebulae.dotSHA2" />
                    
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 nebulae.dotSHA2 --version 0.1.1
                    
#r "nuget: nebulae.dotSHA2, 0.1.1"
                    
#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 nebulae.dotSHA2@0.1.1
                    
#: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=nebulae.dotSHA2&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=nebulae.dotSHA2&version=0.1.1
                    
Install as a Cake Tool

dotSHA2

dotSHA2 is a wrapper around Google's BoringSSL optimized SHA-2 C++ implementation.

It provides both one-shot and incremental hashing (for streaming data).

Span-based, cross-platform, and verified against the NIST test vectors for each hash length (256/384/512) 100% (643/643) passing on all platforms.

In benchmarking, this library is 10-15% faster than Microsoft's System.Security.Cryptography SHA2 implementation, but supports more ergonomic stream hashing.

Tests and benchmarks are included in the Gihub repository.

NuGet

Features

  • Cross-platform: Works on Windows, Linux, and macOS (x64 & Apple Silicon).
  • High performance: Optimized for speed, leveraging native SIMD-enabled code.
  • Easy to use: Simple API for generating keys and signing/verification.
  • Secure: Uses Google's BoringSSL implementation, which is widely trusted in the industry.
  • Minimal dependencies: No external dependencies required (all are included), making it lightweight and easy to integrate.

Requirements

  • .NET 8.0 or later
  • Windows x64, Linux x64, or macOS (x64 & Apple Silicon)

Usage

One-shot hashing example:


using nebulae.dotSHA2;
using System;

ReadOnlySpan<byte> input = "hello world"u8;
Span<byte> hash = stackalloc byte[32]; // SHA-256 = 32 bytes

SHA2.ComputeSHA256(input, hash);

Console.WriteLine(Convert.ToHexString(hash));
// b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

Stream hashing example:


using nebulae.dotSHA2;
using System;
using System.Text;

ReadOnlySpan<byte> part1 = Encoding.UTF8.GetBytes("The quick brown ");
ReadOnlySpan<byte> part2 = Encoding.UTF8.GetBytes("fox jumps over the lazy dog");

using var sha2 = new SHA2(SHA2Algorithm.SHA2_512);
sha2.Update(part1);
sha2.Update(part2);
byte[] hash = sha2.FinalizeHash();

Console.WriteLine(Convert.ToHexString(hash));
// 07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6


Installation

You can install the package via NuGet:


$ dotnet add package nebulae.dotSHA2

Or via git:


$ git clone https://github.com/nebulaeonline/dotSHA2.git
$ cd dotSHA2
$ dotnet build


License

MIT

Roadmap

Unless there are vulnerabilities found, there are no plans to add any new features.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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.
  • 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
0.1.2 246 8/6/2025
0.1.1 224 8/6/2025
0.1.0 231 8/5/2025