Table of Contents

HmacSecureHashAlgorithm1 Class

Definition

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

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

public sealed class HmacSecureHashAlgorithm1 : KeyedCryptoHash<HMACSHA1>, IHash, IConfigurable<ConvertibleOptions>
Inheritance
HmacSecureHashAlgorithm1
Implements
Inherited Members

Examples

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

// Program.cs
using System;
using System.Text;
using Cuemon.Security.Cryptography;
using MyApp.Examples;

HmacSecureHashAlgorithm1Example.Demonstrate();

namespace MyApp.Examples
{
    public static class HmacSecureHashAlgorithm1Example
    {
        public static void Demonstrate()
        {
            var algorithm = new HmacSecureHashAlgorithm1(CreateSecret(), null);
            var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Authenticate this message"));

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

        private static byte[] CreateSecret() => Encoding.UTF8.GetBytes("docs-secret-sha1");
    }
}

Constructors

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

Initializes a new instance of the HmacSecureHashAlgorithm1 class.

See Also

Hash<TOptions>