Creates an instance of the CRC (Cyclic Redundancy Check) class.
The name of the CRC algorithm.
The width of the CRC in bits.
The polynomial used for the CRC calculation.
The initial value for the CRC calculation.
The value to XOR with the final CRC value.
Whether the input bytes should be reflected.
Whether the result should be reflected.
Static
defaultsReturns a list of default CRC configurations.
The list includes various CRC algorithms with their respective parameters:
An array of CRC configurations.
Computes the CRC (Cyclic Redundancy Check) value for the given input bytes.
The input data as an array of numbers or a Buffer.
Static
buildGet built-in CRC by name
Available built-in CRCs:
Name | Width | Polynomial | Initial | Final XOR | Input Reflected | Result Reflected |
---|---|---|---|---|---|---|
CRC8 | 8 | 0x07 | 0x00 | 0x00 | false | false |
CRC8_SAE_J1850 | 8 | 0x1d | 0xff | 0xff | false | false |
CRC8_SAE_J1850_ZERO | 8 | 0x1d | 0x00 | 0x00 | false | false |
CRC8_8H2F | 8 | 0x2f | 0xff | 0xff | false | false |
CRC8_CDMA2000 | 8 | 0x9b | 0xff | 0x00 | false | false |
CRC8_DARC | 8 | 0x39 | 0x00 | 0x00 | true | true |
CRC8_DVB_S2 | 8 | 0xd5 | 0x00 | 0x00 | false | false |
CRC8_EBU | 8 | 0x1d | 0xff | 0x00 | true | true |
CRC8_ICODE | 8 | 0x1d | 0xfd | 0x00 | false | false |
CRC8_ITU | 8 | 0x07 | 0x00 | 0x55 | false | false |
CRC8_MAXIM | 8 | 0x31 | 0x00 | 0x00 | true | true |
CRC8_ROHC | 8 | 0x07 | 0xff | 0x00 | true | true |
CRC8_WCDMA | 8 | 0x9b | 0x00 | 0x00 | true | true |
CRC16_CCIT_ZERO | 16 | 0x1021 | 0x0000 | 0x0000 | false | false |
CRC16_ARC | 16 | 0x8005 | 0x0000 | 0x0000 | true | true |
CRC16_AUG_CCITT | 16 | 0x1021 | 0x1d0f | 0x0000 | false | false |
CRC16_BUYPASS | 16 | 0x8005 | 0x0000 | 0x0000 | false | false |
CRC16_CCITT_FALSE | 16 | 0x1021 | 0xffff | 0x0000 | false | false |
CRC16_CDMA2000 | 16 | 0xc867 | 0xffff | 0x0000 | false | false |
CRC16_DDS_110 | 16 | 0x8005 | 0x800d | 0x0000 | false | false |
CRC16_DECT_R | 16 | 0x0589 | 0x0000 | 0x0001 | false | false |
CRC16_DECT_X | 16 | 0x0589 | 0x0000 | 0x0000 | false | false |
CRC16_DNP | 16 | 0x3d65 | 0x0000 | 0xffff | true | true |
CRC16_EN_13757 | 16 | 0x3d65 | 0x0000 | 0xffff | false | false |
CRC16_GENIBUS | 16 | 0x1021 | 0xffff | 0xffff | false | false |
CRC16_MAXIM | 16 | 0x8005 | 0x0000 | 0xffff | true | true |
CRC16_MCRF4XX | 16 | 0x1021 | 0xffff | 0x0000 | true | true |
CRC16_RIELLO | 16 | 0x1021 | 0xb2aa | 0x0000 | true | true |
CRC16_T10_DIF | 16 | 0x8bb7 | 0x0000 | 0x0000 | false | false |
CRC16_TELEDISK | 16 | 0xa097 | 0x0000 | 0x0000 | false | false |
CRC32 | 32 | 0x04c11db7 | 0xffffffff | 0xffffffff | true | true |
CRC32_BZIP2 | 32 | 0x04c11db7 | 0xffffffff | 0xffffffff | false | false |
CRC32_C | 32 | 0x1edc6f41 | 0xffffffff | 0xffffffff | true | true |
CRC32_D | 32 | 0xa833982b | 0xffffffff | 0xffffffff | true | true |
CRC32_MPEG2 | 32 | 0x04c11db7 | 0xffffffff | 0x00000000 | false | false |
CRC32_POSIX | 32 | 0x04c11db7 | 0x00000000 | 0xffffffff | false | false |
CRC32_Q | 32 | 0x814141ab | 0x00000000 | 0x00000000 | false | false |
CRC32_JAMCRC | 32 | 0x04c11db7 | 0xffffffff | 0x00000000 | true | true |
CRC32_XFER | 32 | 0x000000af | 0x00000000 | 0x00000000 | false | false |
The name of the CRC algorithm to retrieve
The CRC instance if found, undefined otherwise
Static
defaultRetrieves a CRC object from the defaults list by its name.
The name of the CRC object to find.
The CRC object with the specified name, or undefined
if not found.
CRC (Cyclic Redundancy Check) class for computing various CRC algorithms.
This class provides a comprehensive implementation of CRC calculation algorithms commonly used in automotive diagnostics, communication protocols, and data integrity verification. It supports 8-bit, 16-bit, and 32-bit CRC calculations with configurable parameters including polynomial, initial value, final XOR value, and reflection settings.
The class includes a comprehensive set of predefined CRC algorithms and allows custom CRC configurations for specific use cases.
Example