Table of Contents

IHashAlgorithmFactory<T> Interface

Definition

Namespace
Bodu.Security.Cryptography
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
IHashAlgorithmFactory{T}.cs

Defines a factory that produces configured instances of a specific HashAlgorithm implementation.

public interface IHashAlgorithmFactory<out T> where T : HashAlgorithm

Type Parameters

T

The concrete type of HashAlgorithm this factory creates.

Extension Methods

Remarks

This interface decouples the creation and configuration of hash algorithm instances from the logic that consumes them, enabling reusable, testable, and extensible one-shot hash operations via the HashAlgorithmHelper utility class. Implementations may return newly constructed or pooled algorithm instances depending on lifecycle management requirements.

How to obtain an instance. Most callers do not implement this interface directly. Use From<T>(Func<T>) to wrap an algorithm-construction delegate as a DelegateHashAlgorithmFactory<T> - the right pick whenever the algorithm needs configuration (a key, a round count, a variant flag) at the construction site. Implement IHashAlgorithmFactory<T> directly only when adding instance pooling, telemetry, or other cross-cutting behavior around algorithm creation.

How it is consumed. Pass the factory to the static helpers on HashAlgorithmHelper, or its Create() method to MerkleTree. Each call gets a fresh, fully configured algorithm instance - the callers do not need to manage IDisposable lifecycles or thread-safety.

The type argument T must derive from HashAlgorithm.

Methods

Create()

Creates and returns a new instance of the hash algorithm with any necessary configuration applied.

T Create()

Returns

T

A fully initialized T instance, ready for data input.

Applies to

ProductVersions
.NET8, 10

See Also