{"id":9079,"library":"libscrc","title":"Python CRC Calculation Library","description":"libscrc is a Python library designed for calculating various Cyclic Redundancy Check (CRC) values, including CRC3, CRC4, CRC8, CRC16, CRC24, CRC32, CRC64, and CRC82. The latest version is 1.8.1, released on August 18, 2022. While releases are not frequent, the project shows ongoing maintenance and issue tracking through its GitHub repository.","status":"active","version":"1.8.1","language":"en","source_language":"en","source_url":"https://github.com/hex-in/libscrc","tags":["CRC","checksum","CRC3","CRC4","CRC8","CRC16","CRC24","CRC32","CRC64","CRC82","binary","protocol"],"install":[{"cmd":"pip install libscrc","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary import for accessing all CRC functions.","symbol":"libscrc","correct":"import libscrc"}],"quickstart":{"code":"import libscrc\n\n# Calculate CRC16 (Modbus RTU)\ndata_modbus = b'\\x01\\x02\\x03\\x04'\ncrc_modbus = libscrc.modbus(data_modbus)\nprint(f\"CRC16 (Modbus) for {data_modbus.hex()}: {crc_modbus:04X}\")\n\n# Calculate CRC8 (Intel Hex)\ndata_intel = b'1234'\ncrc_intel = libscrc.intel(data_intel)\nprint(f\"CRC8 (Intel Hex) for {data_intel.decode()}: {crc_intel:02X}\")\n\n# Calculate CRC32 (File/WinRAR)\ndata_crc32 = b'example data'\ncrc_file = libscrc.crc32(data_crc32)\nprint(f\"CRC32 (File) for '{data_crc32.decode()}': {crc_file:08X}\")\n\n# Gradual CRC calculation (e.g., XMODEM), supported since v1.4+\ndata_part1 = b'hello'\ndata_part2 = b'world'\ninitial_crc = libscrc.xmodem(data_part1)\nfinal_crc = libscrc.xmodem(data_part2, initial_crc)\nprint(f\"CRC16 (XMODEM) gradually: {final_crc:04X}\")","lang":"python","description":"This quickstart demonstrates how to calculate common CRC types using `libscrc` functions like `modbus`, `intel`, `crc32`, and `xmodem`. It also includes an example of gradual CRC calculation, a feature supported since version 1.4+."},"warnings":[{"fix":"Ensure you have a C compiler and Python development headers installed (e.g., `build-essential` on Linux, Xcode Command Line Tools on macOS, Visual C++ Build Tools on Windows) before attempting `pip install libscrc`.","message":"Installation may fail on systems without a C compiler or specific Python versions due to `libscrc` being a C extension. Pre-built wheels are not available for all Python versions and platforms.","severity":"breaking","affected_versions":"All versions, especially on non-standard architectures or newer Python versions (e.g., Python 3.10+ on macOS, 3.13+ on other platforms)."},{"fix":"If using gradual CRC calculation, verify its behavior with your specific `libscrc` version. Refer to the GitHub README or PyPI changelog for the exact functionality available in your installed version.","message":"The API for 'gradually calculating functions' has seen revisions. It was introduced, reverted in v1.4 (2020-08-04) due to issues, and then updated again in v1.7 (2021-06-07).","severity":"gotcha","affected_versions":"v1.4 - v1.7"},{"fix":"Always confirm the exact CRC standard you need and consult `libscrc`'s documentation or source code to ensure you are calling the correct function with appropriate parameters (e.g., `poly`, `initvalue`) for your specific use case.","message":"CRC algorithms have many variants (polynomial, initial value, XOR-out, reflection settings). Using the wrong `libscrc` function or incorrect parameters will result in an invalid CRC.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the necessary build tools for your operating system. For Debian/Ubuntu: `sudo apt-get install build-essential python3-dev`. For macOS: `xcode-select --install`. For Windows, install 'Desktop development with C++' from Visual Studio Installer.","cause":"The `libscrc` library is a C extension and requires a C compiler (like GCC or Clang) and Python development headers to compile if a pre-built wheel is not available for your system and Python version.","error":"ERROR: Failed building wheel for libscrc"},{"fix":"Review the output of `pip install libscrc` for any error messages, especially those related to building wheels or C compilation. Ensure a C compiler and Python development headers are installed, then try reinstalling.","cause":"This usually indicates that the `libscrc` package failed to install correctly, often due to compilation errors during the C extension build process, even if `pip install` seemed to finish.","error":"ModuleNotFoundError: No module named 'libscrc' (or ImportError)"}]}