![]() |
VOOZH | about |
dotnet add package SauceControl.Blake2Fast --version 2.0.0
NuGet\Install-Package SauceControl.Blake2Fast -Version 2.0.0
<PackageReference Include="SauceControl.Blake2Fast" Version="2.0.0" />
<PackageVersion Include="SauceControl.Blake2Fast" Version="2.0.0" />Directory.Packages.props
<PackageReference Include="SauceControl.Blake2Fast" />Project file
paket add SauceControl.Blake2Fast --version 2.0.0
#r "nuget: SauceControl.Blake2Fast, 2.0.0"
#:package SauceControl.Blake2Fast@2.0.0
#addin nuget:?package=SauceControl.Blake2Fast&version=2.0.0Install as a Cake Addin
#tool nuget:?package=SauceControl.Blake2Fast&version=2.0.0Install as a Cake Tool
These RFC 7693-compliant BLAKE2 implementations have been tuned for high speed and low memory usage. The .NET Core builds use the new x86 SIMD Intrinsics for even greater speed. Span{byte} is used throughout for lower memory overhead compared to byte[] based APIs.
On .NET Core 2.1+, Blake2Fast includes SSE4.1 SIMD-accelerated implementations of both BLAKE2b and BLAKE2s.
On .NET Core 3+, a faster AVX2 implementation of BLAKE2b is included in addition to the SSE4.1 implementation.
The simplest and lightest-weight way to calculate a hash is the all-at-once ComputeHash method.
var hash = Blake2b.ComputeHash(data);
BLAKE2 supports variable digest lengths from 1 to 32 bytes for BLAKE2s or 1 to 64 bytes for BLAKE2b.
var hash = Blake2b.ComputeHash(42, data);
BLAKE2 also natively supports keyed hashing.
var hash = Blake2b.ComputeHash(key, data);
BLAKE2 hashes can be incrementally updated if you do not have the data available all at once.
async Task<byte[]> ComputeHashAsync(Stream data)
{
var hasher = Blake2b.CreateIncrementalHasher();
var buffer = ArrayPool<byte>.Shared.Rent(4096);
int bytesRead;
while ((bytesRead = await data.ReadAsync(buffer, 0, buffer.Length)) > 0)
hasher.Update(new Span<byte>(buffer, 0, bytesRead));
ArrayPool<byte>.Shared.Return(buffer);
return hasher.Finish();
}
The output hash digest can be written to an existing buffer to avoid allocating a new array each time.
Span<byte> buffer = stackalloc byte[Blake2b.DefaultDigestLength];
Blake2b.ComputeAndWriteHash(data, buffer);
This is especially useful when performing an iterative hash, as might be used in a key derivation function.
byte[] DeriveBytes(string password, ReadOnlySpan<byte> salt)
{
// Create key from password, then hash the salt using the key
var pwkey = Blake2b.ComputeHash(Encoding.UTF8.GetBytes(password));
var hbuff = Blake2b.ComputeHash(pwkey, salt);
// Hash the hash lots of times, re-using the same buffer
for (int i = 0; i < 999_999; i++)
Blake2b.ComputeAndWriteHash(pwkey, hbuff, hbuff);
return hbuff;
}
For interoperating with code that uses System.Security.Cryptography primitives, Blake2Fast can create a HashAlgorithm wrapper. The wrapper inherits from HMAC in case keyed hashing is required.
HashAlgorithm is less efficient than the above methods, so use it only when necessary for compatibility.
byte[] WriteDataAndCalculateHash(byte[] data, string outFile)
{
using (var hashAlg = Blake2b.CreateHashAlgorithm())
using (var fileStream = new FileStream(outFile, FileMode.Create))
using (var cryptoStream = new CryptoStream(fileStream, hashAlg, CryptoStreamMode.Write))
{
cryptoStream.Write(data, 0, data.Length);
cryptoStream.FlushFinalBlock();
return hashAlg.Hash;
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp1.0 netcoreapp1.0 was computed. netcoreapp1.1 netcoreapp1.1 was computed. netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 is compatible. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 is compatible. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard1.1 netstandard1.1 is compatible. netstandard1.2 netstandard1.2 was computed. netstandard1.3 netstandard1.3 is compatible. netstandard1.4 netstandard1.4 was computed. netstandard1.5 netstandard1.5 was computed. netstandard1.6 netstandard1.6 was computed. netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net45 net45 is compatible. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen30 tizen30 was computed. tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Universal Windows Platform | uap uap was computed. uap10.0 uap10.0 was computed. |
| Windows Phone | wpa81 wpa81 was computed. |
| Windows Store | netcore netcore was computed. netcore45 netcore45 was computed. netcore451 netcore451 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on SauceControl.Blake2Fast:
| Package | Downloads |
|---|---|
|
CardanoSharp.Wallet
Package Description |
|
|
ActualChat.Core
Package Description |
|
|
FleetSharp
Package Description |
|
|
Orion.CardanoSharp.Wallet
Package Description |
|
|
NextGenSoftware.Holochain.HoloNET.Client
The world's first .NET & Unity client for Holochain. |
Showing the top 4 popular GitHub repositories that depend on SauceControl.Blake2Fast:
| Repository | Stars |
|---|---|
|
baking-bad/tzkt
😼 Awesome Tezos blockchain indexer and API
|
|
|
xoofx/Blake3.NET
Blake3.NET is a fast managed wrapper around the SIMD Rust implementations of the BLAKE3 cryptographic hash function.
|
|
|
netclaw-dev/netclaw
Simple, secure, reliable agents. Self-hosted. Open source. Built with .NET.
|
|
|
CardanoSharp/cardanosharp-wallet
CardanoSharp.Wallet is a Cardano Cryptographic and Serialization library for .NET applications.
|
See https://github.com/saucecontrol/Blake2Fast/releases for release-specific notes.