Skip to content

Implementation of the cryptographic hash, and mac functions of BLAKE2b. For .NET Core, optimized for PinnedMemory, and 64-bit platforms.

License

Notifications You must be signed in to change notification settings

TimothyMeadows/Blake2b.NetCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blake2b.NetCore

License: MIT nuget

Implementation of the cryptographic hash, and mac functions of BLAKE2b. Optimized for PinnedMemory, and 64-bit platforms.

Install

From a command prompt

dotnet add package Blake2b.NetCore
Install-Package Blake2b.NetCore

You can also search for package via your nuget ui / website:

https://www.nuget.org/packages/Blake2b.NetCore/

Examples

You can find more examples in the github examples project.

Hash:

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:

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);

Constructor

Digest size restricted to 160, 256, 384, 512

Blake2b(int digestSize = 512)
Blake2bMac(PinnedMemory<byte> key)
Blake2bMac(PinnedMemory<byte> key, byte[] salt, int digestSize = 512)

Methods

Update the message digest with a single byte.

void Update(byte b)

Update the message digest with a pinned memory byte array.

void UpdateBlock(PinnedMemory<byte> message, int offset, int len)

Update the message digest with a byte array.

void UpdateBlock(byte[] message, int offset, int len)

Produce the final digest value outputting to pinned memory. Key & salt remain until dispose is called.

void DoFinal(PinnedMemory<byte> output, int outOffset)

Reset the digest back to it's initial state for further processing. Key & salt remain until dispose is called.

void Reset()

Clear key & salt, reset digest back to it's initial state.

void Dispose()

About

Implementation of the cryptographic hash, and mac functions of BLAKE2b. For .NET Core, optimized for PinnedMemory, and 64-bit platforms.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages