{"id":4915,"library":"crc","title":"CRC (Cyclic Redundancy Check) Library","description":"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.","status":"active","version":"7.1.0","language":"en","source_language":"en","source_url":"https://github.com/Nicoretti/crc","tags":["crc","checksum","data integrity","error detection"],"install":[{"cmd":"pip install crc","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.8 or newer, but not Python 4.","package":"python","optional":false}],"imports":[{"note":"Introduced in version 5.0.0 after the package structure changed.","symbol":"Calculator","correct":"from crc import Calculator"},{"note":"Introduced in version 5.0.0 after the package structure changed.","symbol":"Crc8","correct":"from crc import Crc8"},{"note":"Introduced in version 5.0.0 after the package structure changed.","symbol":"Crc16","correct":"from crc import Crc16"},{"note":"Introduced in version 5.0.0 after the package structure changed, used for custom CRC setups.","symbol":"Configuration","correct":"from crc import Configuration"}],"quickstart":{"code":"from crc import Calculator, Crc8\n\ndata = bytes([0, 1, 2, 3, 4, 5])\n\n# Create a calculator with a predefined configuration (e.g., CRC-8 CCITT)\ncalculator = Calculator(Crc8.CCITT)\n\n# Calculate the checksum\nchecksum = calculator.checksum(data)\nprint(f\"CRC-8 CCITT checksum: {checksum:#04x}\")\n\n# Verify the checksum\nassert calculator.verify(data, 0xBC)\nprint(\"Checksum verified successfully!\")","lang":"python","description":"Calculates the CRC-8 CCITT checksum for a sample byte sequence and verifies it. This demonstrates the basic usage of a predefined CRC configuration."},"warnings":[{"fix":"Replace `Crc16.CCITT` with `Crc16.XMODEM` if you relied on the previous values, or with `Crc16.KERMIT` for the new official CCITT parameters.","message":"The `Crc16.CCITT` configuration was renamed to `Crc16.XMODEM`. The new `Crc16.KERMIT` configuration now provides the 'official' CCITT parameters.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Upgrade your Python environment to version 3.8 or newer.","message":"Python 3.7 support has been removed.","severity":"breaking","affected_versions":">=6.0.0"},{"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.","message":"The `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.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Ensure all imports follow standard package patterns, e.g., `from crc import Calculator, Crc8`.","message":"The 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.","severity":"breaking","affected_versions":">=5.0.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"<6.1.2"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}