IHashAlgorithmFactory<T> Interface
Definition
- Namespace
- Bodu.Security.Cryptography
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
Defines a factory that produces configured instances of a specific HashAlgorithm implementation.
public interface IHashAlgorithmFactory<out T> where T : HashAlgorithm
Type Parameters
TThe 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
Tinstance, ready for data input.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |