nebulae.dotSHA2
0.1.1
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
<PackageReference Include="nebulae.dotSHA2" Version="0.1.1" />
<PackageVersion Include="nebulae.dotSHA2" Version="0.1.1" />
<PackageReference Include="nebulae.dotSHA2" />
paket add nebulae.dotSHA2 --version 0.1.1
#r "nuget: nebulae.dotSHA2, 0.1.1"
#:package nebulae.dotSHA2@0.1.1
#addin nuget:?package=nebulae.dotSHA2&version=0.1.1
#tool nuget:?package=nebulae.dotSHA2&version=0.1.1
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.
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 | Versions 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. |
-
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.