UnkeyedHashFactory Class
Definition
- Namespace
- Cuemon.Security.Cryptography
- Assemblies
- Cuemon.Security.Cryptography.dll
Provides access to factory methods for creating and configuring Hash instances based on UnkeyedCryptoHash<TAlgorithm>.
public static class UnkeyedHashFactory
- Inheritance
-
UnkeyedHashFactory
Examples
The following example demonstrates how to compute SHA-256 and SHA-512 hashes for data integrity using UnkeyedHashFactory. It hashes a sample input and prints the hexadecimal digest for each algorithm.
using System;
using System.Text;
using Cuemon.Security.Cryptography;
namespace Cuemon.Security.Cryptography;
public class UnkeyedHashFactoryExample
{
public void Demonstrate()
{
var sha256 = UnkeyedHashFactory.CreateCryptoSha256();
var input = "Data to hash";
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(input));
Console.WriteLine($"SHA-256: {BitConverter.ToString(hash.GetBytes()).Replace("-", "")}");
var sha512 = UnkeyedHashFactory.CreateCryptoSha512();
hash = sha512.ComputeHash(Encoding.UTF8.GetBytes(input));
Console.WriteLine($"SHA-512: {BitConverter.ToString(hash.GetBytes()).Replace("-", "")}");
}
}
Methods
| Name | Description |
|---|---|
| CreateCrypto(UnkeyedCryptoAlgorithm, Action<ConvertibleOptions>) | Creates an instance of a cryptographic implementation that derives from UnkeyedCryptoHash<TAlgorithm> with the specified |
| CreateCryptoMd5(Action<ConvertibleOptions>) | Creates an instance of MessageDigest5. |
| CreateCryptoSha1(Action<ConvertibleOptions>) | Creates an instance of SecureHashAlgorithm1. |
| CreateCryptoSha256(Action<ConvertibleOptions>) | Creates an instance of SecureHashAlgorithm256. |
| CreateCryptoSha384(Action<ConvertibleOptions>) | Creates an instance of SecureHashAlgorithm384. |
| CreateCryptoSha512(Action<ConvertibleOptions>) | Creates an instance of SecureHashAlgorithm512. |
| CreateCryptoSha512Slash256(Action<ConvertibleOptions>) | Creates an instance of SecureHashAlgorithm512256. |