Skip to content

CRC

A pure Python library to calculate and verify CRC checksums.

Checks Coverage License Downloads Supported Python Versions PyPi Package Checks Coverage License Downloads Supported Python Versions PyPi Package

What it does

from crc import Calculator, Crc8

calculator = Calculator(Crc8.CCITT)

calculator.checksum(b"123456789")      # (1)!
calculator.verify(b"123456789", 0xF4)  # (2)!
  1. Returns the checksum as an int, here 0xF4.
  2. Returns True if the data matches the expected checksum.

Why use it

  • Python No dependencies


    Does not contribute to potentional dependency conflicts, easy to vendor if needed.

  • Batteries included


    More than 20 predefined configurations, plus support for custom configurations.

  • Portable


    As pure Python library with no native dependencies it runs wherever a python runs.

  • Flexible input


    Works with bytes, int, files, streams, iterables and anything convertible to bytes.

Where to go next

  • Getting started


    Install the library and calculate your first checksum.

    Getting started

  • Usage guide


    Task oriented guides for calculating, verifying and configuring CRCs.

    Usage guide

  • Configurations


    Browse every CRC configuration that ships with the library, including all of their parameters.

    Configurations

  • API reference


    Detailed documentation for the Calculator, Configuration and the low level register types.

    API reference

  • Command line


    Generate CRC lookup tables straight from your terminal with the bundled crc command.

    CLI

  • Development


    Set up a development environment and learn how to contribute.

    Development

References & resources