Class Blake2B
Convenience calls for performing Blake2 hashes.
Inherited Members
Namespace: Isopoh.Cryptography.Blake2b
Assembly: Isopoh.Cryptography.Blake2b.dll
Syntax
public static class Blake2B
Fields
| Edit this page View SourceBufferMinimumTotalSize
Gets the minimum total size in bytes of the Blake2B work buffer.
Declaration
public const int BufferMinimumTotalSize = 512
Field Value
| Type | Description |
|---|---|
| int |
NoKeyBufferMinimumTotalSize
Gets the minimum total size in bytes of the Blake2B work buffer if there is no Blake2BConfig.Key.
Declaration
public const int NoKeyBufferMinimumTotalSize = 384
Field Value
| Type | Description |
|---|---|
| int |
OutputLength
The output length of the Blake2 hash in bytes.
Declaration
public const int OutputLength = 64
Field Value
| Type | Description |
|---|---|
| int |
Remarks
This is the maximum length buffer a Blake2 hash can produce Blake2 will always hash to this length even when configured to hash to a shorter value - the final step is to truncate the result.
Note, the length of the expected result is hashed into the result so the OutputLength-byte buffer will hold different values depending on the configured output length. Do not run Blake2 using the default length and then truncate and expect to get the same result as if you configured Blake2 to produce a shorter result.
Methods
| Edit this page View SourceComputeHash(byte[], Blake2BConfig, SecureArrayCall)
Perform a Blake2 hash on the given buffer using the given Blake2 configuration.
Declaration
public static Memory<byte> ComputeHash(byte[] data, Blake2BConfig config, SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The buffer to hash. |
| Blake2BConfig | config | The configuration to use. |
| SecureArrayCall | secureArrayCall | The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall. |
Returns
| Type | Description |
|---|---|
| Memory<byte> | The hash of the buffer. |
ComputeHash(byte[], SecureArrayCall)
Perform a default Blake2 hash on the given buffer.
Declaration
public static Memory<byte> ComputeHash(byte[] data, SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The buffer to hash. |
| SecureArrayCall | secureArrayCall | The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall. |
Returns
| Type | Description |
|---|---|
| Memory<byte> | The hash of the buffer. |
ComputeHash(byte[], int, int, Blake2BConfig?, SecureArrayCall)
Perform a Blake2 hash on the given buffer using the given Blake2 configuration.
Declaration
public static Memory<byte> ComputeHash(byte[] data, int start, int count, Blake2BConfig? config, SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The buffer to hash. |
| int | start | The byte in the buffer to start hashing. |
| int | count | The number of bytes to hash. |
| Blake2BConfig | config | The configuration to use. |
| SecureArrayCall | secureArrayCall | The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall. |
Returns
| Type | Description |
|---|---|
| Memory<byte> | The hash of the buffer. |
ComputeHash(byte[], int, int, SecureArrayCall)
Perform a default Blake2 hash on the given buffer.
Declaration
public static Memory<byte> ComputeHash(byte[] data, int start, int count, SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The buffer to hash. |
| int | start | The byte in the buffer to start hashing. |
| int | count | The number of bytes to hash. |
| SecureArrayCall | secureArrayCall | The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall. |
Returns
| Type | Description |
|---|---|
| Memory<byte> | The hash of the buffer. |
ComputeHash(ReadOnlySpan<byte>, Blake2BConfig?, Memory<byte>)
Perform a Blake2 hash on the given buffer using the given Blake2 configuration.
Declaration
public static Memory<byte> ComputeHash(ReadOnlySpan<byte> data, Blake2BConfig? config, Memory<byte> blake2BBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | data | The buffer to hash. |
| Blake2BConfig | config | The configuration to use. |
| Memory<byte> | blake2BBuffer | Must be at least Blake2BHasher.BufferMinimumTotalSize + ( |
Returns
| Type | Description |
|---|---|
| Memory<byte> | The hash of the buffer. |
Create(Blake2BConfig?, SecureArrayCall)
Create a Blake2 hash with the given configuration.
Declaration
public static Hasher Create(Blake2BConfig? config, SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| Blake2BConfig | config | The configuration to use. |
| SecureArrayCall | secureArrayCall | The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall. |
Returns
| Type | Description |
|---|---|
| Hasher | A Hasher that can be converted to a HashAlgorithm. |
Create(Blake2BConfig?, Memory<byte>)
Create a Blake2 hash with the given configuration.
Declaration
public static Hasher Create(Blake2BConfig? config, Memory<byte> blake2BBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| Blake2BConfig | config | The configuration to use. |
| Memory<byte> | blake2BBuffer | Must be at least Blake2B.BufferMinimumTotalSize + ( |
Returns
| Type | Description |
|---|---|
| Hasher | A Hasher that can be converted to a HashAlgorithm. |
Create(SecureArrayCall)
Create a default Blake2 hash.
Declaration
public static Hasher Create(SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| SecureArrayCall | secureArrayCall | The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall. |
Returns
| Type | Description |
|---|---|
| Hasher | A Hasher that can be converted to a HashAlgorithm. |
Create(Memory<byte>)
Create a default Blake2 hash.
Declaration
public static Hasher Create(Memory<byte> blake2BBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| Memory<byte> | blake2BBuffer | Typically, must have length of at least BufferMinimumTotalSize. If there isn't any key, must have length of at least NoKeyBufferMinimumTotalSize. |
Returns
| Type | Description |
|---|---|
| Hasher | A Hasher that can be converted to a HashAlgorithm. |