Class CpIncrementalHash
Provides support for computing a hash or HMAC value incrementally across several segments.
Implements
Inherited Members
Namespace: CryptoPro.Security.Cryptography
Assembly: CryptoPro.Security.Cryptography.dll
Syntax
public sealed class CpIncrementalHash : IDisposable
Properties
AlgorithmName
Get the name of the algorithm being performed.
Declaration
public HashAlgorithmName AlgorithmName { get; }
Property Value
| Type | Description |
|---|---|
| HashAlgorithmName |
Methods
AppendData(byte[])
Append the entire contents of data to the data already processed in the hash or HMAC.
Declaration
public void AppendData(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The data to process. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ObjectDisposedException | The object has already been disposed. |
AppendData(byte[], int, int)
Append count bytes of data, starting at offset,
to the data already processed in the hash or HMAC.
Declaration
public void AppendData(byte[] data, int offset, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The data to process. |
| int | offset | The offset into the byte array from which to begin using data. |
| int | count | The number of bytes in the array to use as data. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
| ArgumentOutOfRangeException |
|
| ArgumentException |
|
| ObjectDisposedException | The object has already been disposed. |
AppendData(ReadOnlySpan<byte>)
Declaration
public void AppendData(ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | data |
CreateHMAC(HashAlgorithmName, byte[])
Create an CpIncrementalHash for the Hash-based Message Authentication Code (HMAC)
algorithm utilizing the hash algorithm specified by hashAlgorithm, and a
key specified by key.
Declaration
public static CpIncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, byte[] key)
Parameters
| Type | Name | Description |
|---|---|---|
| HashAlgorithmName | hashAlgorithm | The name of the hash algorithm to perform within the HMAC. |
| byte[] | key | The secret key for the HMAC. The key can be any length, but a key longer than the output size
of the hash algorithm specified by |
Returns
| Type | Description |
|---|---|
| CpIncrementalHash | An CpIncrementalHash instance ready to compute the hash algorithm specified
by |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| CryptographicException |
|
CreateHash(HashAlgorithmName)
Create an CpIncrementalHash for the algorithm specified by hashAlgorithm.
Declaration
public static CpIncrementalHash CreateHash(HashAlgorithmName hashAlgorithm)
Parameters
| Type | Name | Description |
|---|---|---|
| HashAlgorithmName | hashAlgorithm | The name of the hash algorithm to perform. |
Returns
| Type | Description |
|---|---|
| CpIncrementalHash | An CpIncrementalHash instance ready to compute the hash algorithm specified
by |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| CryptographicException |
|
Dispose()
Release all resources used by the current instance of the CpIncrementalHash class.
Declaration
public void Dispose()
GetHashAndReset()
Retrieve the hash or HMAC for the data accumulated from prior calls to AppendData(byte[]), and return to the state the object was in at construction.
Declaration
public byte[] GetHashAndReset()
Returns
| Type | Description |
|---|---|
| byte[] | The computed hash or HMAC. |
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | The object has already been disposed. |
TryGetHashAndReset(Span<byte>, out int)
Declaration
public bool TryGetHashAndReset(Span<byte> destination, out int bytesWritten)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<byte> | destination | |
| int | bytesWritten |
Returns
| Type | Description |
|---|---|
| bool |