CyclicRedundancyCheck32 Class
Definition
- Assemblies
- Cuemon.Core.dll
Provides a CRC-32 implementation of the CRC (Cyclic Redundancy Check) checksum algorithm for 32-bit hash values. This class cannot be inherited.
public sealed class CyclicRedundancyCheck32 : CyclicRedundancyCheck, IHash, IConfigurable<CyclicRedundancyCheckOptions>
- Inheritance
-
objectCyclicRedundancyCheck32
- Implements
- Inherited Members
Examples
The following example shows how to compute a CRC-32 checksum with the common reflected configuration.
using System;
using System.Text;
using Cuemon;
using Cuemon.Security;
namespace MyApp.Examples;
public static class CyclicRedundancyCheck32Example
{
public static void Demonstrate()
{
var checksum = new CyclicRedundancyCheck32(setup: options =>
{
options.ByteOrder = Endianness.BigEndian;
options.ReflectInput = true;
options.ReflectOutput = true;
});
HashResult result = checksum.ComputeHash(Encoding.ASCII.GetBytes("123456789"));
Console.WriteLine(result.ToHexadecimalString().ToLowerInvariant());
Console.WriteLine(checksum.InitialValue);
Console.WriteLine(checksum.FinalXor);
var alternate = new CyclicRedundancyCheck32(polynomial: 0xEDB88320, initialValue: 0xFFFFFFFF, finalXor: 0xFFFFFFFF);
Console.WriteLine(alternate.ComputeHash("Cuemon").ToBase64String());
}
}
Constructors
| Name | Description |
|---|---|
| CyclicRedundancyCheck32(uint, uint, uint, Action<CyclicRedundancyCheckOptions>) | Initializes a new instance of the CyclicRedundancyCheck32 class. |
Methods
| Name | Description |
|---|---|
| ComputeHash(byte[]) | Computes the hash value for the specified byte array. |
| PolynomialIndexInitializer(byte) | Returns the initial value for the specified |
| PolynomialSlotCalculator(ref ulong, ulong) | Computes the polynomial |