Fast CRC Checksum Library

0.3.5 · active · verified Mon Apr 13

fastcrc is a hyper-fast Python module for computing CRC (Cyclic Redundancy Check) checksums across 8, 16, 32, and 64-bit standards. It leverages highly optimized Rust code for performance. The current version is 0.3.5, and it maintains an active release cadence with several updates per year, focusing on performance, platform support, and new CRC algorithms.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the fastcrc library to compute checksums for various CRC standards (8, 16, 32, 64-bit) using different algorithms. It also shows an example of chained CRC calculation using the optional 'initial' parameter.

from fastcrc import crc8, crc16, crc32, crc64

data = b"123456789"

# Compute CRC-8 using the cdma2000 algorithm
print(f"crc8 checksum with cdma2000 algorithm: {crc8.cdma2000(data)}")

# Compute CRC-16 using the xmodem algorithm
print(f"crc16 checksum with xmodem algorithm: {crc16.xmodem(data)}")

# Compute CRC-32 using the aixm algorithm
print(f"crc32 checksum with aixm algorithm: {crc32.aixm(data)}")

# Compute CRC-64 using the ecma_182 algorithm
print(f"crc64 checksum with ecma_182 algorithm: {crc64.ecma_182(data)}")

# Chained CRC calculation with initial data
initial_crc = crc16.xmodem(b'1234')
final_crc = crc16.xmodem(b'56789', initial_crc)
print(f"crc16 checksum with xmodem algorithm (chained): {final_crc}")

view raw JSON →