fastcrc

Read the Docs PyPI Python - Version

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

Installation

pip install fastcrc

Usage

from fastcrc import crc16, crc32, crc64

data = b"123456789"
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)}")

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-rs.

API Reference

CRC 16

Compute a CRC-16 checksum of data.

fastcrc.crc16.arc(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.cdma2000(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.cms(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.dds_110(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.dect_r(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.dect_x(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.dnp(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.en_13757(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.genibus(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.gsm(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.ibm_3740(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.ibm_sdlc(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

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: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.kermit(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.lj1200(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.maxim_dow(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.mcrf4xx(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.modbus(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.nrsc_5(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.opensafety_a(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.opensafety_b(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.profibus(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.riello(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.spi_fujitsu(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.t10_dif(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.teledisk(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.tms37157(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.umts(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.usb(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc16.xmodem(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

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: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.autosar(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.base91_d(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.bzip2(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.cd_rom_edc(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.cksum(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.iscsi(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.iso_hdlc(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.jamcrc(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.mpeg_2(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc32.xfer(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

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: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc64.go_iso(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc64.we(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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

fastcrc.crc64.xz(data: bytes)int[source]

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

Parameters

data (bytes) – The data to be computed

Returns

The checksum

Return type

int

Raises

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