Blake2b.Net 1.0.0

dotnet add package Blake2b.Net --version 1.0.0                
NuGet\Install-Package Blake2b.Net -Version 1.0.0                
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="Blake2b.Net" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blake2b.Net --version 1.0.0                
#r "nuget: Blake2b.Net, 1.0.0"                
#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.
// Install Blake2b.Net as a Cake Addin
#addin nuget:?package=Blake2b.Net&version=1.0.0

// Install Blake2b.Net as a Cake Tool
#tool nuget:?package=Blake2b.Net&version=1.0.0                

Blake2b.Net

License: MIT nuget

Blake2b.Net provides an implementation of the cryptographic hash and MAC functions of the BLAKE2b algorithm, optimized for SIMD hardware instructions and PinnedMemory support.

Features

  • Supports cryptographic hash generation using BLAKE2b.
  • MAC (Message Authentication Code) functionality with key and salt.
  • Optimized for SIMD instructions to ensure fast performance on supported hardware.
  • Secure key and buffer management with PinnedMemory to avoid sensitive data leaks.

Installation

You can install the package via NuGet:

.NET CLI

dotnet add package Blake2b.Net

Package Manager

Install-Package Blake2b.Net

NuGet Website

You can also search for and install the package via the NuGet UI or from the following link: Blake2b.Net on NuGet

Usage Examples

Hashing Example:

var digest = new Blake2b();
using var exampleHash = new PinnedMemory<byte>(new byte[digest.GetLength()]);
digest.UpdateBlock(new PinnedMemory<byte>(new byte[] {63, 61, 77, 20, 63, 61, 77, 20, 63, 61, 77}, false), 0, 11);
digest.DoFinal(exampleHash, 0);

MAC Example:

var digest = new Blake2bMac(new PinnedMemory<byte>(new byte[] {63, 61, 77, 20, 63, 61, 77}, false));
using var exampleHash = new PinnedMemory<byte>(new byte[digest.GetLength()]);
digest.UpdateBlock(new PinnedMemory<byte>(new byte[] {63, 61, 77, 20, 63, 61, 77, 20, 63, 61, 77}, false), 0, 11);
digest.DoFinal(exampleHash, 0);

API Documentation

Constructors

Blake2b(int digestSize = 512)
  • Initializes a new instance of the Blake2b class with the specified digest size.
  • Supported digest sizes: 160, 256, 384, 512 bits.
  • Default size: 512 bits.
Blake2bMac(PinnedMemory<byte> key)
  • Initializes a new instance of the Blake2bMac class with the specified key for MAC generation.
  • The key should be provided in the form of a PinnedMemory<byte> object.
Blake2bMac(PinnedMemory<byte> key, byte[] salt, int digestSize = 512)
  • Initializes a new instance of the Blake2bMac class with the specified key, salt, and digest size.
  • Supported digest sizes: 160, 256, 384, 512 bits.
  • Default size: 512 bits.
  • The salt must be 16 bytes long.

Methods

void Update(byte b)
  • Updates the message digest with a single byte.
void UpdateBlock(PinnedMemory<byte> message, int offset, int len)
  • Updates the message digest with a pinned memory byte array.
void UpdateBlock(byte[] message, int offset, int len)
  • Updates the message digest with a regular byte array.
void DoFinal(PinnedMemory<byte> output, int outOffset)
  • Produces the final digest value and outputs it to the specified PinnedMemory<byte> buffer.
void Reset()
  • Resets the digest to its initial state for further processing.
  • The key and salt remain until the object is disposed.
void Dispose()
  • Clears the key and salt, resets the digest to its initial state, and releases resources.

Performance Considerations

The BLAKE2b algorithm is optimized for modern SIMD instructions (such as AVX and SSE) to provide enhanced performance on supported hardware. This ensures that hashing and MAC operations are processed efficiently, even with large datasets.

Security Considerations

This library utilizes PinnedMemory to ensure that sensitive data such as keys and message buffers are not moved by the garbage collector, reducing the risk of memory leaks. Ensure that you call Dispose() on any PinnedMemory object or classes that use it to securely clear and free memory after use.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 95 10/16/2024