Table of Contents

Enum CyclicRedundancyCheckAlgorithm

Namespace
Cuemon.Security
Assembly
Cuemon.Core.dll

Different models of the CRC algorithm family.

public enum CyclicRedundancyCheckAlgorithm

Fields

Crc32 = 0

CRC-32; also known as CRC-32/ISO-HDLC, CRC-32/ADCCP, CRC-32/V-42, CRC-32/XZ, PKZIP.

Crc32Autosar = 1

CRC-32/AUTOSAR.

Crc32Bzip2 = 2

CRC-32/BZIP2; also known as CRC-32/AAL5, CRC-32/DECT-B, B-CRC-32.

Crc32C = 3

CRC32-C; also known as CRC-32/ISCSI, CRC-32/BASE91-C, CRC-32/CASTAGNOLI, CRC-32/INTERLAKEN.

Crc32CdRomEdc = 4

CRC-32/CD-ROM-EDC.

Crc32D = 5

CRC-32D; also known as BASE91-D.

Crc32Jamcrc = 9

CRC-32/JAMCRC.

Crc32Mpeg2 = 6

CRC-32/MPEG-2.

Crc32Posix = 7

CRC-32/POSIX; also known as CRC-32/CKSUM, CKSUM.

Crc32Q = 8

CRC-32Q; also known as CRC-32/AIXM.

Crc32Xfer = 10

CRC-32/XFER.

Crc64 = 20

CRC-64; also known as CRC-64/ECMA-182.

Crc64GoIso = 21

CRC-64/GO-ISO.

Crc64We = 22

CRC-64/WE.

Crc64Xz = 23

CRC-64/XZ; also, mistakenly, known as: CRC-64/GO-ECMA.

Examples

The following example demonstrates how to use the enum to select a specific CRC algorithm variant.

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)

}
}