Hashing It Out

While .NET finally includes CRC-32 and CRC-64 algorithms, it stops at bare minimum and offers only a single standard polynomial for each. Perfectly sufficient if one wants to create something from scratch but woefully inadequate when it comes to integrating with other software.

You see, CRC is just the method of computation and it's not sufficient to fully describe the result. What you need is polynomial and there's a bunch of them. At any useful bit length you will find many "standard" polynomials. While .NETs solution gives probably most common 32 and 64 bit variant, it doesn't cover shorter bit lengths nor does it allow for custom polynomial.

Well, for that purpose I created a library following the same inheritance-from-NonCryptographicHashAlgorithm-class pattern. Not only does it allow for 8, 16, 32, and 64 bit widths, but it also offers a bunch of well-known polynomials in addition to custom polynomial support.

Below is the list of currently supported variants and, as always, code is available on GitHub.

CRC-8 CRC-16 CRC-32 CRC-64
ATM ACORN AAL5 ECMA-182
AUTOSAR ARC ADCCP GO-ECMA
BLUETOOTH AUG-CCITT AIXM GO-ISO
C2 AUTOSAR AUTOSAR MS
CCITT BUYPASS BASE91-C REDIS
CDMA2000 CCITT BASE91-D WE
DARC CCITT-FALSE BZIP2 XZ
DVB-S2 CCITT-TRUE CASTAGNOLI
GSM-A CDMA2000 CD-ROM-EDC
GSM-B CMS CKSUM
HITAG DARC DECT-B
I-432-1 DDS-110 IEEE-802.3
I-CODE DECT-R INTERLAKEN
ITU DECT-X ISCSI
LTE DNP ISO-HDLC
MAXIM EN-13757 JAMCRC
MAXIM-DOW EPC MPEG-2
MIFARE EPC-C1G2 PKZIP
MIFARE-MAD GENIBUS POSIX
NRSC-5 GSM V-42
OPENSAFETY I-CODE XFER
ROHC IBM-3740 XZ
SAE-J1850 IBM-SDLC
SMBUS IEC-61158-2
TECH-3250 IEEE 802.3
WCDMA2000 ISO-HDLD
ISO-IEC-14443-3-A
ISO-IEC-14443-3-B
KERMIT
LHA
LJ1200
LTE
MAXIM
MAXIM-DOW
MCRF4XX
MODBUS
NRSC-5
OPENSAFETY-A
OPENSAFETY-B
PROFIBUS
RIELLO
SPI-FUJITSU
T10-DIF
TELEDISK
TMS37157
UMTS
USB
V-41-LSB
V-41-MSB
VERIFONE
X-25
XMODEM
ZMODEM

Leave a Reply

Your email address will not be published. Required fields are marked *