fastcrc

GitHub Workflow Status Read the Docs PyPI - Downloads PyPI

A hyper-fast Python module for computing CRC(8, 16, 32, 64) checksum.

Installation

fastcrc needs Python 3.8 or newer. Prebuilt wheels are available for recent CPython versions on Linux, macOS and Windows, so on most machines this is all it takes:

pip install fastcrc

If pip can’t find a wheel for your interpreter it falls back to building from source, which needs a Rust toolchain (1.89 or newer).

Usage

from fastcrc import crc8, crc16, crc32, crc64

data = b"123456789"
print(f"crc8 checksum with cdma2000 algorithm: {crc8.cdma2000(data)}")
print(f"crc16 checksum with xmodem algorithm: {crc16.xmodem(data)}")
print(f"crc32 checksum with aixm algorithm: {crc32.aixm(data)}")
print(f"crc64 checksum with ecma_182 algorithm: {crc64.ecma_182(data)}")
print(f"crc16 checksum with xmodem algorithm (with initial data): {crc16.xmodem(b'56789', crc16.xmodem(b'1234'))}")

# Any bytes-like object works without copying, e.g. a slice of a larger buffer.
buffer = bytearray(b"header:123456789")
print(f"crc32 checksum of a memoryview slice: {crc32.iscsi(memoryview(buffer)[7:])}")

Notes

  • data may be any object that supports the buffer protocol (bytes, bytearray, memoryview, array, mmap, NumPy arrays, …). It is read in place without copying, so do not modify it from another thread while its checksum is being computed.

  • Inputs of 16 KiB and more are processed with the GIL released, so threads can compute checksums in parallel. The free-threaded build of CPython is supported.

Performance

CRC-16, CRC-32 and CRC-64 use SIMD carry-less multiplication (PCLMULQDQ/VPCLMULQDQ on x86, PMULL on aarch64) with a table-based fallback elsewhere; CRC-8 uses slice-by-16 tables. The best method for the CPU is picked at run time, so the wheels run everywhere.

Single-threaded throughput on an AMD Ryzen 7 9700X (Zen 5) with CPython 3.14, in GB/s:

Input

crc32.iscsi

crc32.iso_hdlc

crc16.xmodem

crc64.xz

crc8.smbus

64 B

2.3

1.5

1.5

1.3

2.4

1 KiB

21.5

21.5

22.8

20.9

8.2

1 MiB

86.8

87.0

86.4

86.6

9.4

Full tables for every algorithm, per-call latencies, multi-threaded scaling and the harness to reproduce them are in benchmarks/README.md.

Documentation

fastcrc’s documentation can be found at https://fastcrc.readthedocs.io

License

fastcrc is licensed under MIT License.

Thanks

fastcrc is made possible by crc-fast.

API Reference

CRC 8

Compute a CRC-8 checksum of data.

fastcrc.crc8.autosar(data, initial=None)

Compute a CRC-8 checksum of data with the autosar algorithm.

Algorithm parameters:
  • poly: 0x2f

  • init: 0xff

  • xorout: 0xff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.bluetooth(data, initial=None)

Compute a CRC-8 checksum of data with the bluetooth algorithm.

Algorithm parameters:
  • poly: 0xa7

  • init: 0x00

  • xorout: 0x00

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.cdma2000(data, initial=None)

Compute a CRC-8 checksum of data with the cdma2000 algorithm.

Algorithm parameters:
  • poly: 0x9b

  • init: 0xff

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.darc(data, initial=None)

Compute a CRC-8 checksum of data with the darc algorithm.

Algorithm parameters:
  • poly: 0x39

  • init: 0x00

  • xorout: 0x00

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.dvb_s2(data, initial=None)

Compute a CRC-8 checksum of data with the dvb_s2 algorithm.

Algorithm parameters:
  • poly: 0xd5

  • init: 0x00

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.gsm_a(data, initial=None)

Compute a CRC-8 checksum of data with the gsm_a algorithm.

Algorithm parameters:
  • poly: 0x1d

  • init: 0x00

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.gsm_b(data, initial=None)

Compute a CRC-8 checksum of data with the gsm_b algorithm.

Algorithm parameters:
  • poly: 0x49

  • init: 0x00

  • xorout: 0xff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.i_432_1(data, initial=None)

Compute a CRC-8 checksum of data with the i_432_1 algorithm.

Algorithm parameters:
  • poly: 0x07

  • init: 0x00

  • xorout: 0x55

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.i_code(data, initial=None)

Compute a CRC-8 checksum of data with the i_code algorithm.

Algorithm parameters:
  • poly: 0x1d

  • init: 0xfd

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.lte(data, initial=None)

Compute a CRC-8 checksum of data with the lte algorithm.

Algorithm parameters:
  • poly: 0x9b

  • init: 0x00

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.maxim_dow(data, initial=None)

Compute a CRC-8 checksum of data with the maxim_dow algorithm.

Algorithm parameters:
  • poly: 0x31

  • init: 0x00

  • xorout: 0x00

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.mifare_mad(data, initial=None)

Compute a CRC-8 checksum of data with the mifare_mad algorithm.

Algorithm parameters:
  • poly: 0x1d

  • init: 0xc7

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.nrsc_5(data, initial=None)

Compute a CRC-8 checksum of data with the nrsc_5 algorithm.

Algorithm parameters:
  • poly: 0x31

  • init: 0xff

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.opensafety(data, initial=None)

Compute a CRC-8 checksum of data with the opensafety algorithm.

Algorithm parameters:
  • poly: 0x2f

  • init: 0x00

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.rohc(data, initial=None)

Compute a CRC-8 checksum of data with the rohc algorithm.

Algorithm parameters:
  • poly: 0x07

  • init: 0xff

  • xorout: 0x00

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.sae_j1850(data, initial=None)

Compute a CRC-8 checksum of data with the sae_j1850 algorithm.

Algorithm parameters:
  • poly: 0x1d

  • init: 0xff

  • xorout: 0xff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.smbus(data, initial=None)

Compute a CRC-8 checksum of data with the smbus algorithm.

Algorithm parameters:
  • poly: 0x07

  • init: 0x00

  • xorout: 0x00

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.tech_3250(data, initial=None)

Compute a CRC-8 checksum of data with the tech_3250 algorithm.

Algorithm parameters:
  • poly: 0x1d

  • init: 0xff

  • xorout: 0x00

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc8.wcdma(data, initial=None)

Compute a CRC-8 checksum of data with the wcdma algorithm.

Algorithm parameters:
  • poly: 0x9b

  • init: 0x00

  • xorout: 0x00

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

CRC 16

Compute a CRC-16 checksum of data.

fastcrc.crc16.arc(data, initial=None)

Compute a CRC-16 checksum of data with the arc algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0x0000

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.autosar(data, initial=None)

Compute a CRC-16 checksum of data with the autosar algorithm.

This is the CRC16 routine of the AUTOSAR CRC library, also known as CRC-16/CCITT-FALSE; it is the same algorithm as ibm_3740.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xffff

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.cdma2000(data, initial=None)

Compute a CRC-16 checksum of data with the cdma2000 algorithm.

Algorithm parameters:
  • poly: 0xc867

  • init: 0xffff

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.cms(data, initial=None)

Compute a CRC-16 checksum of data with the cms algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0xffff

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.dds_110(data, initial=None)

Compute a CRC-16 checksum of data with the dds 110 algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0x800d

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.dect_r(data, initial=None)

Compute a CRC-16 checksum of data with the dect r algorithm.

Algorithm parameters:
  • poly: 0x0589

  • init: 0x0000

  • xorout: 0x0001

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.dect_x(data, initial=None)

Compute a CRC-16 checksum of data with the dect x algorithm.

Algorithm parameters:
  • poly: 0x0589

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.dnp(data, initial=None)

Compute a CRC-16 checksum of data with the dnp algorithm.

Algorithm parameters:
  • poly: 0x3d65

  • init: 0x0000

  • xorout: 0xffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.en_13757(data, initial=None)

Compute a CRC-16 checksum of data with the en 13757 algorithm.

Algorithm parameters:
  • poly: 0x3d65

  • init: 0x0000

  • xorout: 0xffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.genibus(data, initial=None)

Compute a CRC-16 checksum of data with the genibus algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xffff

  • xorout: 0xffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.gsm(data, initial=None)

Compute a CRC-16 checksum of data with the gsm algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0x0000

  • xorout: 0xffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.ibm_3740(data, initial=None)

Compute a CRC-16 checksum of data with the ibm 3740 algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xffff

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.ibm_refin(data, initial=None)

Compute a CRC-16 checksum of data with the ibm refin algorithm.

This method may be removed in the future.

Algorithm parameters:
  • poly: 0x8005

  • init: 0x0000

  • xorout: 0x0000

  • refin: True

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.ibm_sdlc(data, initial=None)

Compute a CRC-16 checksum of data with the ibm sdlc algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xffff

  • xorout: 0xffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.iso_iec_14443_3_a(data, initial=None)

Compute a CRC-16 checksum of data with the iso iec 14443 3 a algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xc6c6

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.kermit(data, initial=None)

Compute a CRC-16 checksum of data with the kermit algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0x0000

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.lj1200(data, initial=None)

Compute a CRC-16 checksum of data with the lj1200 algorithm.

Algorithm parameters:
  • poly: 0x6f63

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.maxim_dow(data, initial=None)

Compute a CRC-16 checksum of data with the maxim dow algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0x0000

  • xorout: 0xffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.mcrf4xx(data, initial=None)

Compute a CRC-16 checksum of data with the mcrf4xx algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xffff

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.modbus(data, initial=None)

Compute a CRC-16 checksum of data with the modbus algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0xffff

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.nrsc_5(data, initial=None)

Compute a CRC-16 checksum of data with the nrsc 5 algorithm.

Algorithm parameters:
  • poly: 0x080b

  • init: 0xffff

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.opensafety_a(data, initial=None)

Compute a CRC-16 checksum of data with the opensafety a algorithm.

Algorithm parameters:
  • poly: 0x5935

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.opensafety_b(data, initial=None)

Compute a CRC-16 checksum of data with the opensafety b algorithm.

Algorithm parameters:
  • poly: 0x755b

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.profibus(data, initial=None)

Compute a CRC-16 checksum of data with the profibus algorithm.

Algorithm parameters:
  • poly: 0x1dcf

  • init: 0xffff

  • xorout: 0xffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.riello(data, initial=None)

Compute a CRC-16 checksum of data with the riello algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0xb2aa

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.spi_fujitsu(data, initial=None)

Compute a CRC-16 checksum of data with the spi fujitsu algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0x1d0f

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.t10_dif(data, initial=None)

Compute a CRC-16 checksum of data with the t10 dif algorithm.

Algorithm parameters:
  • poly: 0x8bb7

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.teledisk(data, initial=None)

Compute a CRC-16 checksum of data with the teledisk algorithm.

Algorithm parameters:
  • poly: 0xa097

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.tms37157(data, initial=None)

Compute a CRC-16 checksum of data with the tms37157 algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0x89ec

  • xorout: 0x0000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.umts(data, initial=None)

Compute a CRC-16 checksum of data with the umts algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.usb(data, initial=None)

Compute a CRC-16 checksum of data with the usb algorithm.

Algorithm parameters:
  • poly: 0x8005

  • init: 0xffff

  • xorout: 0xffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc16.xmodem(data, initial=None)

Compute a CRC-16 checksum of data with the xmodem algorithm.

Algorithm parameters:
  • poly: 0x1021

  • init: 0x0000

  • xorout: 0x0000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

CRC 32

Compute a CRC-32 checksum of data.

fastcrc.crc32.aixm(data, initial=None)

Compute a CRC-32 checksum of data with the aixm algorithm.

Algorithm parameters:
  • poly: 0x814141ab

  • init: 0x00000000

  • xorout: 0x00000000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.autosar(data, initial=None)

Compute a CRC-32 checksum of data with the autosar algorithm.

Algorithm parameters:
  • poly: 0xf4acfb13

  • init: 0xffffffff

  • xorout: 0xffffffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.base91_d(data, initial=None)

Compute a CRC-32 checksum of data with the base91 d algorithm.

Algorithm parameters:
  • poly: 0xa833982b

  • init: 0xffffffff

  • xorout: 0xffffffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.bzip2(data, initial=None)

Compute a CRC-32 checksum of data with the bzip2 algorithm.

Algorithm parameters:
  • poly: 0x04c11db7

  • init: 0xffffffff

  • xorout: 0xffffffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.cd_rom_edc(data, initial=None)

Compute a CRC-32 checksum of data with the cd rom edc algorithm.

Algorithm parameters:
  • poly: 0x8001801b

  • init: 0x00000000

  • xorout: 0x00000000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.cksum(data, initial=None)

Compute a CRC-32 checksum of data with the cksum algorithm.

Algorithm parameters:
  • poly: 0x04c11db7

  • init: 0x00000000

  • xorout: 0xffffffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.iscsi(data, initial=None)

Compute a CRC-32 checksum of data with the iscsi algorithm.

Algorithm parameters:
  • poly: 0x1edc6f41

  • init: 0xffffffff

  • xorout: 0xffffffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.iso_hdlc(data, initial=None)

Compute a CRC-32 checksum of data with the iso hdlc algorithm.

Algorithm parameters:
  • poly: 0x04c11db7

  • init: 0xffffffff

  • xorout: 0xffffffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.jamcrc(data, initial=None)

Compute a CRC-32 checksum of data with the jamcrc algorithm.

Algorithm parameters:
  • poly: 0x04c11db7

  • init: 0xffffffff

  • xorout: 0x00000000

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.k_reversed_reciprocal_refin(data, initial=None)

Compute a CRC-32 checksum of data with the k reversed reciprocal refin algorithm.

This method may be removed in the future.

Algorithm parameters:
  • poly: 0xba0dc66b

  • init: 0x00000000

  • xorout: 0x00000000

  • refin: True

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.mpeg_2(data, initial=None)

Compute a CRC-32 checksum of data with the mpeg 2 algorithm.

Algorithm parameters:
  • poly: 0x04c11db7

  • init: 0xffffffff

  • xorout: 0x00000000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc32.xfer(data, initial=None)

Compute a CRC-32 checksum of data with the xfer algorithm.

Algorithm parameters:
  • poly: 0x000000af

  • init: 0x00000000

  • xorout: 0x00000000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

CRC 64

Compute a CRC-64 checksum of data.

fastcrc.crc64.ecma_182(data, initial=None)

Compute a CRC-64 checksum of data with the ecma 182 algorithm.

Algorithm parameters:
  • poly: 0x42f0e1eba9ea3693

  • init: 0x0000000000000000

  • xorout: 0x0000000000000000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc64.go_iso(data, initial=None)

Compute a CRC-64 checksum of data with the go iso algorithm.

Algorithm parameters:
  • poly: 0x000000000000001b

  • init: 0xffffffffffffffff

  • xorout: 0xffffffffffffffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc64.tms570_iso(data, initial=None)

Compute a CRC-64 checksum of data with the tms570_iso algorithm.

Algorithm parameters:
  • poly: 0x000000000000001b

  • init: 0x0000000000000000

  • xorout: 0x0000000000000000

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc64.we(data, initial=None)

Compute a CRC-64 checksum of data with the we algorithm.

Algorithm parameters:
  • poly: 0x42f0e1eba9ea3693

  • init: 0xffffffffffffffff

  • xorout: 0xffffffffffffffff

  • refin: False

  • refout: False

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object

fastcrc.crc64.xz(data, initial=None)

Compute a CRC-64 checksum of data with the xz algorithm.

Algorithm parameters:
  • poly: 0x42f0e1eba9ea3693

  • init: 0xffffffffffffffff

  • xorout: 0xffffffffffffffff

  • refin: True

  • refout: True

Parameters:
  • data – The data to be computed, any bytes-like object; a mutable buffer must not be modified by another thread while its checksum is computed

  • initial (Optional[int]) – The optional starting value of the checksum

Returns:

The checksum

Return type:

int

Raises:

TypeError – if the data is not a bytes-like object