Table of Contents

DigestHashFactory Class

Definition

Namespace
Cuemon.AspNetCore.Authentication.Digest
Assemblies
Cuemon.AspNetCore.Authentication.dll
Source
src/Cuemon.AspNetCore.Authentication/Digest/DigestHashFactory.cs

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

Name Description
CreateCrypto(DigestCryptoAlgorithm)

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