Table of Contents

HmacSecureHashAlgorithm256 Class

Definition

Namespace
Cuemon.Security.Cryptography
Assemblies
Cuemon.Security.Cryptography.dll
Source
src/Cuemon.Security.Cryptography/HmacSecureHashAlgorithm256.cs

Provides a Hash-based Message Authentication Code (HMAC) by using the SHA256 hash function. This class cannot be inherited. Implements the KeyedCryptoHash<TAlgorithm>

public sealed class HmacSecureHashAlgorithm256 : KeyedCryptoHash<HMACSHA256>, IHash, IConfigurable<ConvertibleOptions>
Inheritance
HmacSecureHashAlgorithm256
Implements
Inherited Members

Examples

The following example demonstrates how to compute an HMAC-SHA256 hash with .

using System;
using System.Text;
using Cuemon.Security.Cryptography;

namespace MyApp.Examples;

public static class HmacSecureHashAlgorithm256Example
{
    public static void Demonstrate()
    {
        var secret = Encoding.UTF8.GetBytes("unittest-secret");
        var payload = Encoding.UTF8.GetBytes("Authenticate this message");
        var algorithm = new HmacSecureHashAlgorithm256(secret, null);
        var result = algorithm.ComputeHash(payload);

        Console.WriteLine(result.GetBytes().Length);
        Console.WriteLine(result.ToHexadecimalString());
    }
}

Constructors

Name Description
HmacSecureHashAlgorithm256(byte[], Action<ConvertibleOptions>)

Initializes a new instance of the HmacSecureHashAlgorithm256 class.

See Also

Hash<TOptions>