Registry / serialization / crc
library8.0.0pypypi✓ verified 23d ago

The `crc` library provides pure Python implementations for calculating, verifying, and configuring Cyclic Redundancy Check (CRC) checksums. It supports various predefined CRC configurations (e.g., CRC8, CRC16, CRC32, CRC64) and allows for custom configurations. Currently at version 7.1.0, the library is actively maintained with regular releases, often including new CRC configurations and bug fixes, and requires Python >=3.8 and <4.0.

pip install crc
INSTALL
IMPORT
SIG · CRC
C
crc
serializationpythonv8.0.0
Install
1.5s avg
Import
47ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v7.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.050s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.044s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Calculator
from crc import Calculator
Introduced in version 5.0.0 after the package structure changed.
Crc8
from crc import Crc8
Introduced in version 5.0.0 after the package structure changed.
Crc16
from crc import Crc16
Introduced in version 5.0.0 after the package structure changed.
Configuration
from crc import Configuration
Introduced in version 5.0.0 after the package structure changed, used for custom CRC setups.

Calculates the CRC-8 CCITT checksum for a sample byte sequence and verifies it. This demonstrates the basic usage of a predefined CRC configuration.

from crc import Calculator, Crc8 data = bytes([0, 1, 2, 3, 4, 5]) # Create a calculator with a predefined configuration (e.g., CRC-8 CCITT) calculator = Calculator(Crc8.CCITT) # Calculate the checksum checksum = calculator.checksum(data) print(f"CRC-8 CCITT checksum: {checksum:#04x}") # Verify the checksum assert calculator.verify(data, 0xBC) print("Checksum verified successfully!")
Debug
Known issues
breakingThe `Crc16.CCITT` configuration was renamed to `Crc16.XMODEM`. The new `Crc16.KERMIT` configuration now provides the 'official' CCITT parameters.
fix
Replace `Crc16.CCITT` with `Crc16.XMODEM` if you relied on the previous values, or with `Crc16.KERMIT` for the new official CCITT parameters.
affects: >=7.0.0
breakingPython 3.7 support has been removed.
fix
Upgrade your Python environment to version 3.8 or newer.
affects: >=6.0.0
breakingThe `SAEJ1850` configuration was adjusted to match the official specification. For users relying on the previously misconfigured values, a new configuration named `SAE_J1850_ZERO` was added.
fix
If your application depends on the original (pre-6.0.0) `SAEJ1850` values, switch to `SAE_J1850_ZERO`. Otherwise, continue using `SAEJ1850` for the corrected specification.
affects: >=6.0.0
breakingThe library transitioned from a single-file module (`crc.py`) to an src-based package layout. Direct imports that assumed a single `crc.py` file will no longer work.
fix
Ensure all imports follow standard package patterns, e.g., `from crc import Calculator, Crc8`.
affects: >=5.0.0
gotchaThe `digest` function had unstable return values, particularly in configurations that required reverse output and when the CRC register was manually manipulated. Standard `Calculator` usage was generally unaffected.
fix
Upgrade to version 6.1.2 or newer to resolve this issue. In older affected versions, avoid manual manipulation of CRC registers if relying on reverse output configurations.
affects: <6.1.2
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'crc'
The 'crc' library has not been installed in your Python environment or the Python interpreter cannot find it.
fix
Run `pip install crc` to install the library.
TypeError: a bytes-like object is required, not 'str'
CRC calculation functions typically expect binary data (bytes) as input, but a string (str) was provided.
fix
Encode the string to bytes before passing it to the checksum method, e.g., `data.encode('utf-8')`.
AttributeError: 'Configuration' object has no attribute 'checksum'
You are attempting to call the `checksum` method directly on a CRC configuration object (e.g., `Crc8.CCITT`), which only defines the CRC parameters, not the calculation method. The calculation method belongs to a `Calculator` instance.
fix
First, create a `Calculator` instance with the desired configuration, then call `checksum` on the calculator, e.g., `calculator = Calculator(Crc8.CCITT)` and then `calculator.checksum(data)`.
Upgrade
Version history
8.0.0latest on PyPI · released Aug 29, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.8 or newer, but not Python 4.
Agent activity
16 hits · last 30 days
node
10
Resources