Class CyclicRedundancyCheck32
- Namespace
- Cuemon.Security
- Assembly
- 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
-
CyclicRedundancyCheck32
- Implements
- Inherited Members
Constructors
CyclicRedundancyCheck32(UInt32, UInt32, UInt32, Action<CyclicRedundancyCheckOptions>)
Initializes a new instance of the CyclicRedundancyCheck32 class.
public CyclicRedundancyCheck32(uint polynomial = 79764919U, uint initialValue = 4294967295U, uint finalXor = 4294967295U, Action<CyclicRedundancyCheckOptions> setup = null)
Parameters
polynomial
UInt32This is a binary value that should be specified as a hexadecimal number. Default is
0x4C11DB7
.initialValue
UInt32This parameter specifies the initial value of the register when the algorithm starts. Default is
0xFFFFFFFF
.finalXor
UInt32This is an W-bit value that should be specified as a hexadecimal number. Default is
0xFFFFFFFF
.setup
Action<CyclicRedundancyCheckOptions>The CyclicRedundancyCheckOptions which may be configured.
Methods
ComputeHash(Byte[])
Computes the hash value for the specified byte[].
public override HashResult ComputeHash(byte[] input)
Parameters
input
Byte[]The byte[] to compute the hash code for.
Returns
- HashResult
A HashResult containing the computed hash code of the specified
input
.
Remarks
Inspiration and praises goes to http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html
PolynomialIndexInitializer(Byte)
Returns the initial value for the specified index
of the polynomial LookupTable.
protected override ulong PolynomialIndexInitializer(byte index)
Parameters
index
ByteThe index of the array of polynomial values ranging from 0 to 255.
Returns
- UInt64
The initial value for the specified
index
.
PolynomialSlotCalculator(ref UInt64, UInt64)
Computes the polynomial checksum
value in steps of 8 (0-7) x 256 (0-255) giving a total of 2048 times.
protected override void PolynomialSlotCalculator(ref ulong checksum, ulong polynomial)
Parameters
checksum
UInt64The checksum that is iterated 8 times (0-7) in 256 steps (0-255).
polynomial
UInt64The polynomial value.