Enum CyclicRedundancyCheckAlgorithm
Different models of the CRC algorithm family.
public enum CyclicRedundancyCheckAlgorithm
Fields
Crc32 = 0CRC-32; also known as CRC-32/ISO-HDLC, CRC-32/ADCCP, CRC-32/V-42, CRC-32/XZ, PKZIP.
Crc32Autosar = 1CRC-32/AUTOSAR.
Crc32Bzip2 = 2CRC-32/BZIP2; also known as CRC-32/AAL5, CRC-32/DECT-B, B-CRC-32.
Crc32C = 3CRC32-C; also known as CRC-32/ISCSI, CRC-32/BASE91-C, CRC-32/CASTAGNOLI, CRC-32/INTERLAKEN.
Crc32CdRomEdc = 4CRC-32/CD-ROM-EDC.
Crc32D = 5CRC-32D; also known as BASE91-D.
Crc32Jamcrc = 9CRC-32/JAMCRC.
Crc32Mpeg2 = 6CRC-32/MPEG-2.
Crc32Posix = 7CRC-32/POSIX; also known as CRC-32/CKSUM, CKSUM.
Crc32Q = 8CRC-32Q; also known as CRC-32/AIXM.
Crc32Xfer = 10CRC-32/XFER.
Crc64 = 20CRC-64; also known as CRC-64/ECMA-182.
Crc64GoIso = 21CRC-64/GO-ISO.
Crc64We = 22CRC-64/WE.
Crc64Xz = 23CRC-64/XZ; also, mistakenly, known as: CRC-64/GO-ECMA.
Examples
The following example demonstrates how to use the
using System;
using Cuemon.Security; // for CyclicRedundancyCheckAlgorithm
namespace MyApp.Examples;
public class CyclicRedundancyCheckAlgorithmExample
{
public void Demonstrate()
{
// Select commonly used CRC algorithms
CyclicRedundancyCheckAlgorithm crc32 = CyclicRedundancyCheckAlgorithm.Crc32;
CyclicRedundancyCheckAlgorithm crc32C = CyclicRedundancyCheckAlgorithm.Crc32C;
CyclicRedundancyCheckAlgorithm crc64 = CyclicRedundancyCheckAlgorithm.Crc64;
Console.WriteLine(crc32); // Crc32
Console.WriteLine(crc32C); // Crc32C
Console.WriteLine(crc64); // Crc64
// Switch on algorithm
string GetDescription(CyclicRedundancyCheckAlgorithm algo) => algo switch
{
CyclicRedundancyCheckAlgorithm.Crc32 => "CRC-32 (ISO-HDLC, PKZIP)",
CyclicRedundancyCheckAlgorithm.Crc32C => "CRC-32C (ISCSI, Castagnoli)",
CyclicRedundancyCheckAlgorithm.Crc64 => "CRC-64 (ECMA-182)",
_ => "Unknown"
};
Console.WriteLine(GetDescription(crc32C)); // CRC-32C (ISCSI, Castagnoli)
}
}