{"id":3945,"library":"crccheck","title":"crccheck library","description":"crccheck is a Python library (currently v1.3.1) for calculating various Cyclic Redundancy Checks (CRCs) and checksums from binary data. It includes over 170 CRC algorithms and simple additive/XOR checksums. The library maintains an active, though somewhat irregular, release schedule, with recent updates adding new CRC algorithms.","status":"active","version":"1.3.1","language":"en","source_language":"en","source_url":"https://github.com/MartinScharrer/crccheck","tags":["CRC","checksum","data integrity","error detection","binary"],"install":[{"cmd":"pip install crccheck","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"Crc32","correct":"from crccheck.crc import Crc32"},{"symbol":"Checksum8","correct":"from crccheck.checksum import Checksum8"},{"note":"Use the general Crc class for custom CRC parameters not pre-implemented.","symbol":"Crc","correct":"from crccheck.crc import Crc"}],"quickstart":{"code":"from crccheck.crc import Crc32\n\ndata_bytes = bytearray.fromhex(\"DEADBEEF01020304\")\n\n# Quick calculation for a single data block\ncalculated_crc = Crc32.calc(data_bytes)\nprint(f\"CRC-32 for {data_bytes.hex()}: {calculated_crc:08X}\")\n\n# Calculation over multiple data blocks\nmulti_block_data1 = b\"Hello\"\nmulti_block_data2 = b\"World\"\n\ncrc_instance = Crc32()\ncrc_instance.process(multi_block_data1)\ncrc_instance.process(multi_block_data2)\nfinal_crc = crc_instance.final()\nprint(f\"CRC-32 for multiple blocks: {final_crc:08X}\")","lang":"python","description":"Demonstrates how to perform a quick CRC calculation on a single data block and how to process multiple data blocks sequentially. Input data should be in bytes or bytearray format."},"warnings":[{"fix":"Ensure your code uses `crccheck` for imports and `byteorder='big'` or `byteorder='little'` for endianness specification.","message":"Older versions (prior to v0.3) had a different package name (not specified but taken on PyPI) and used `bigendian=True/False` arguments. These were changed to `crccheck` and `byteorder='big'/'little'` respectively.","severity":"breaking","affected_versions":"<0.3"},{"fix":"Convert string data to bytes using `your_string.encode('utf-8')` or `bytearray.fromhex('...')` before passing it to `crccheck` functions.","message":"Input data for CRC and checksum calculations must be binary (bytes or bytearray) in Python 3. Passing a regular string will result in a TypeError or incorrect results, as the library operates on byte sequences.","severity":"gotcha","affected_versions":"All versions (Python 3)"},{"fix":"For fragmented or streaming data, use an instance: `crc_inst = Crc32(); crc_inst.process(block1); crc_inst.process(block2); final_crc = crc_inst.final()`.","message":"The `calc()` class method is suitable for quick calculations on a single complete data block. For calculations involving multiple sequential data blocks, you must instantiate the CRC/checksum class, feed data using `process()`, and retrieve the final result with `final()`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}