Library crc

To use this library in your code:

import crypto.crc
Cyclic Redundancy Check (CRC).
CRC is an error-detection code.

Classes

CRC-16/ARC checksum state.

CRC-16/AUG-CCITT checksum state.

CRC-16/BUYPASS checksum state.

CRC-16/CCITT-FALSE checksum state.

CRC-16/CDMA2000 checksum state.

CRC-16/DDS-110 checksum state.

CRC-16/DECT-R checksum state.

CRC-16/DECT-X checksum state.

CRC-16/DNP checksum state.

CRC-16/EN-13757 checksum state.

CRC-16/GENIBUS checksum state.

CRC-16/KERMIT checksum state.

CRC-16/MAXIM checksum state.

CRC-16/MCRF4XX checksum state.

CRC-16/MODBUS checksum state.

CRC-16/RIELLO checksum state.

CRC-16/T10-DIF checksum state.

CRC-16/TELEDISK checksum state.

CRC-16/TMS37157 checksum state.

CRC-16/USB checksum state.

CRC-16/X-25 checksum state.

CRC-16/XMODEM checksum state.

CRC-32 checksum state.

CRC-32/BZIP2 checksum state.

CRC-32C checksum state.

CRC-32D checksum state.

CRC-32/JAMCRC checksum state.

CRC-32/MPEG-2 checksum state.

CRC-32/POSIX checksum state.

CRC-32Q checksum state.

CRC-32/XFER checksum state.

CRC-64/XZ checksum state.

CRC-8 checksum state.

CRC-8/CDMA2000 checksum state.

CRC-8/DARC checksum state.

CRC-8/DVB-S2 checksum state.

CRC-8/EBU checksum state.

CRC-8/I-CODE checksum state.

CRC-8/ITU checksum state.

CRC-8/MAXIM checksum state.

CRC-8/ROHC checksum state.

CRC-8/WCDMA checksum state.

CRC-A checksum state.

Functions

crc-a data/Data -> int
Computes the CRC-A checksum of the given data.
Returns the checksum as a 16-bit integer.
Note
Crccalc.com lists the initial state of the CRC as 0xC6C6, whereas we use the initial value of 0x6363, the bit reversed value. This value is the one that gives the correct result (matching crccalc.com's check) when run with our code.

Computes the CRC-16/ARC checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/AUG-CCITT checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/BUYPASS checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/CCITT-FALSE checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/CDMA2000 checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/DDS-110 checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/DECT-R checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/DECT-X checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/DNP checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/EN-13757 checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/GENIBUS checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/KERMIT checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/MAXIM checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/MCRF4XX checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/MODBUS checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/RIELLO checksum of the given data.
Returns the checksum as a 16-bit integer.
Note
Crccalc.com lists the initial state of the CRC as 0xB2AA, whereas we use the initial value of 0x554D, the bit reversed value. This value is the one that gives the correct result (matching crccalc.com's check) when run with our code, and it is also the value given in the specification at https://networkupstools.org/protocols/riello/PSGPSER-0104.pdf

Computes the CRC-16/T10-DIF checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/TELEDISK checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/TMS37157 checksum of the given data.
Returns the checksum as a 16-bit integer.
Note
Crccalc.com lists the initial state of the CRC as 0x89EC, whereas we use the initial value of 0x3791, the bit reversed value. This value is the one that gives the correct result (matching crccalc.com's check) when run with our code.

Computes the CRC-16/USB checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/X-25 checksum of the given data.
Returns the checksum as a 16-bit integer.

Computes the CRC-16/XMODEM checksum of the given data.
Returns the checksum as a 16-bit integer.

crc32 data/Data -> int
Computes the CRC-32 checksum of the given data.
Returns the checksum as a 32-bit integer.

Computes the CRC-32/BZIP2 checksum of the given data.
Returns the checksum as a 32-bit integer.

Computes the CRC-32/JAMCRC checksum of the given data.
Returns the checksum as a 32-bit integer.

Computes the CRC-32/MPEG-2 checksum of the given data.
Returns the checksum as a 32-bit integer.

Computes the CRC-32/POSIX checksum of the given data.
Returns the checksum as a 32-bit integer.

Computes the CRC-32/XFER checksum of the given data.
Returns the checksum as a 32-bit integer.

crc32c data/Data -> int
Computes the CRC-32C checksum of the given data.
Returns the checksum as a 32-bit integer.

crc32d data/Data -> int
Computes the CRC-32D checksum of the given data.
Returns the checksum as a 32-bit integer.

crc32q data/Data -> int
Computes the CRC-32Q checksum of the given data.
Returns the checksum as a 32-bit integer.

crc64-xz data/Data -> int
Computes the CRC-64/XZ checksum of the given data.
Returns the checksum as a 32-bit integer.

crc8 data/Data -> int
Computes the CRC-8 checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/CDMA2000 checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/DARC checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/DVB-S2 checksum of the given data.
Returns the checksum as an 8-bit integer.

crc8-ebu data/Data -> int
Computes the CRC-8/EBU checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/I-CODE checksum of the given data.
Returns the checksum as an 8-bit integer.

crc8-itu data/Data -> int
Computes the CRC-8/ITU checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/MAXIM checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/ROHC checksum of the given data.
Returns the checksum as an 8-bit integer.

Computes the CRC-8/WCDMA checksum of the given data.
Returns the checksum as an 8-bit integer.