Table of Contents

Class DigestHashFactory

Namespace
Cuemon.AspNetCore.Authentication.Digest
Assembly
Cuemon.AspNetCore.Authentication.dll

Provides access to factory methods for creating and configuring Hash instances based on UnkeyedCryptoHash<TAlgorithm>.

public static class DigestHashFactory
Inheritance
DigestHashFactory

Examples

The following example demonstrates how to create a cryptographic hash instance using DigestHashFactory with a specified algorithm.

using System;
using System.Text;
using Cuemon.AspNetCore.Authentication.Digest;
using Cuemon.Security;

namespace MyApp.Examples;

public static class DigestHashFactoryExample
{
    public static void Demonstrate()
    {
        Hash hash = DigestHashFactory.CreateCrypto(DigestCryptoAlgorithm.Sha256);

        var bytes = Encoding.UTF8.GetBytes("hello-world");
        var result = hash.ComputeHash(bytes);

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

Methods

CreateCrypto(DigestCryptoAlgorithm)

Creates an instance of a cryptographic implementation that derives from UnkeyedCryptoHash<TAlgorithm> with the specified algorithm.

public static Hash CreateCrypto(DigestCryptoAlgorithm algorithm = DigestCryptoAlgorithm.Sha256)

Parameters

algorithm DigestCryptoAlgorithm

The DigestCryptoAlgorithm that defines the cryptographic implementation. Default is Sha256.

Returns

Hash

A Hash implementation of the by parameter specified algorithm.