crc32c 2.8


pip install crc32c

  Latest version

Released: Oct 17, 2025


Meta
Author: Rodrigo Tobar
Requires Python: >=3.7

Classifiers

License
  • OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)

Operating System
  • OS Independent

Programming Language
  • C
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
https://github.com/ICRAR/crc32c/workflows/Build%20and%20release%20to%20PyPI/badge.svg?branch=master https://badge.fury.io/py/crc32c.svg

This package implements the crc32c checksum algorithm. It automatically chooses between a hardware-based implementation (using the CRC32C SSE 4.2 instruction of Intel CPUs, and the crc32* instructions on ARMv8 CPUs), or a software-based one when no hardware support can be found.

Because crc32c is in PyPI, you can install it with:

pip install crc32c

Supported platforms are Linux and OSX using the gcc and clang compilers, and Windows using the Visual Studio compiler. Other compilers in Windows (MinGW for instance) might work. Binary wheels are also provided in PyPI for major platforms/architectures.

The project is using certain gcc/clang compiler extensions to support building hardware-specific functions that might not be supported by older compiler versions.

Usage

API

The core function exposed by this module is crc32c(data, value=0, gil_release_mode=-1). It computes the CRC32C checksum of data starting with an initial value checksum, similarly to how the built-in binascii.crc32 works. It can thus be used like this:

print(crc32c.crc32c(b'hello world'))
# 3381945770
crc = crc32c.crc32c(b'hello')
print(crc32c.crc32c(b' world', value=crc))
# 3381945770

In older versions, the function exposed by this module was called crc32. That name is still present but deprecated, and will be removed in new versions of the library.

The gil_release_mode keyword argument specifies whether a call of this library shall release or keep the Global Interpreter Lock. It can be set to the following values:

  • Negative: Only release the GIL when data >= 32KiB

  • 0: Never release the GIL

  • Positive: Always release the GIL

The gil_release_mode parameter doesn’t have any effect on free-threaded Python builds.

On top of the crc32c function, a CRC32CHash(data=b"", gil_release_mode=-1) class is also offered. It is modelled after the “hash objects” of the hashlib module of the standard library. It also offers a checksum property:

crc32c_hash = crc32c.CRC32CHash()
crc32c_hash.update(b'hello')
crc32c_hash.update(b' world')
print(crc32c_hash.checksum == crc32c.crc32c(b'hello world'))
# True
print(crc32c_hash.digest())
# b'\xc9\x94e\xaa'
digest_as_int = int.from_bytes(crc32c_hash.digest(), "big")
print(digest_as_int == crc32c.crc32c(b'hello world'))
# True

For more details see the documentation on hash objects.

Additionally one can consult the following module-level values:

  • hardware_based indicates if the algorithm in use is software- or hardware-based.

  • big_endian indicates whether the platform is big endian or not.

A benchmarking utility can be found when executing the crc32c.benchmark module. Consult its help with the -h flag for options.

CLI

A simple crc32c script is also installed alongside the package. It is also available when running the crc32c module (e.g., python -mcrc32c). It takes one or more filenames, calculates their crc32c checksums, and prints them on stdout. See crc32c -h for all available options.

Implementation details

By default, if your CPU doesn’t have CRC32C hardware support, the package will fallback to use a software implementation of the crc32c checksum algorithm. This behavior can be changed by setting the CRC32C_SW_MODE environment variable to one of the following values:

  • auto: same as if unset, will eventually be discontinued.

  • force: use software implementation regardless of hardware support.

  • none: issue a RuntimeWarning when importing the module, and a RuntimeError when executing the crc32c function, if no hardware support is found. In versions of this package up to 2.6 an ImportError was raised when importing the module instead. In 1.x versions this was the default behaviour.

Setting the CRC32C_SKIP_HW_PROBE to 1 simulates platforms without hardware support. This is available mostly for internal testing purposes.

The software algorithm is based on Intel’s slice-by-8 package, with some adaptations done by Evan Jones and packaging provided by Ferry Toth. Further adaptations were required to make the code more portable and fit for inclusion within this python package.

The Intel SSE 4.2 algorithm is based on Mark Adler’s code, with some modifications required to make the code more portable and fit for inclusion within this python package.

The ARMv8 hardware implementation is based on Google’s crc32c C++ library.

License

This package is licensed under the LGPL-2.1 license.

The original slice-by-8 software algorithm is licensed under the 2-clause BSD licence.

Further modifications to the slice-by-8 software algorithm are licensed under a 3-clause BSD licence

The original Intel SSE 4.2 crc32c algorithm’s code is licensed under a custom license embedded in the crc32c_adler.c file.

The original crc32c ARMv8 hardware code is licensed under a 3-clause BSD license.

Wheel compatibility matrix

Platform CPython 3.8 CPython 3.9 CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython (additional flags: t) 3.13 CPython (additional flags: t) 3.14 PyPy 3.11 (pp73)
macosx_10_13_universal2
macosx_10_13_x86_64
macosx_10_15_x86_64
macosx_10_9_universal2
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux1_x86_64
manylinux2014_aarch64
manylinux_2_17_aarch64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
manylinux_2_5_x86_64
musllinux_1_2_aarch64
musllinux_1_2_x86_64
win32
win_amd64

Files in release

crc32c-2.8-cp310-cp310-macosx_10_9_universal2.whl (64.8KiB)
crc32c-2.8-cp310-cp310-macosx_10_9_x86_64.whl (61.5KiB)
crc32c-2.8-cp310-cp310-macosx_11_0_arm64.whl (60.1KiB)
crc32c-2.8-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (77.5KiB)
crc32c-2.8-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.1KiB)
crc32c-2.8-cp310-cp310-musllinux_1_2_aarch64.whl (78.1KiB)
crc32c-2.8-cp310-cp310-musllinux_1_2_x86_64.whl (77.4KiB)
crc32c-2.8-cp310-cp310-win32.whl (63.4KiB)
crc32c-2.8-cp310-cp310-win_amd64.whl (65.1KiB)
crc32c-2.8-cp311-cp311-macosx_10_9_universal2.whl (64.8KiB)
crc32c-2.8-cp311-cp311-macosx_10_9_x86_64.whl (61.5KiB)
crc32c-2.8-cp311-cp311-macosx_11_0_arm64.whl (60.1KiB)
crc32c-2.8-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (78.3KiB)
crc32c-2.8-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.8KiB)
crc32c-2.8-cp311-cp311-musllinux_1_2_aarch64.whl (78.9KiB)
crc32c-2.8-cp311-cp311-musllinux_1_2_x86_64.whl (78.2KiB)
crc32c-2.8-cp311-cp311-win32.whl (63.4KiB)
crc32c-2.8-cp311-cp311-win_amd64.whl (65.1KiB)
crc32c-2.8-cp312-cp312-macosx_10_13_universal2.whl (64.8KiB)
crc32c-2.8-cp312-cp312-macosx_10_13_x86_64.whl (61.6KiB)
crc32c-2.8-cp312-cp312-macosx_11_0_arm64.whl (60.1KiB)
crc32c-2.8-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (78.2KiB)
crc32c-2.8-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.6KiB)
crc32c-2.8-cp312-cp312-musllinux_1_2_aarch64.whl (78.7KiB)
crc32c-2.8-cp312-cp312-musllinux_1_2_x86_64.whl (78.0KiB)
crc32c-2.8-cp312-cp312-win32.whl (63.4KiB)
crc32c-2.8-cp312-cp312-win_amd64.whl (65.1KiB)
crc32c-2.8-cp313-cp313-macosx_10_13_universal2.whl (64.8KiB)
crc32c-2.8-cp313-cp313-macosx_10_13_x86_64.whl (61.6KiB)
crc32c-2.8-cp313-cp313-macosx_11_0_arm64.whl (60.1KiB)
crc32c-2.8-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (78.1KiB)
crc32c-2.8-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.6KiB)
crc32c-2.8-cp313-cp313-musllinux_1_2_aarch64.whl (78.8KiB)
crc32c-2.8-cp313-cp313-musllinux_1_2_x86_64.whl (78.0KiB)
crc32c-2.8-cp313-cp313-win32.whl (63.4KiB)
crc32c-2.8-cp313-cp313-win_amd64.whl (65.1KiB)
crc32c-2.8-cp313-cp313t-macosx_10_13_universal2.whl (64.7KiB)
crc32c-2.8-cp313-cp313t-macosx_10_13_x86_64.whl (61.5KiB)
crc32c-2.8-cp313-cp313t-macosx_11_0_arm64.whl (60.0KiB)
crc32c-2.8-cp313-cp313t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (77.3KiB)
crc32c-2.8-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.1KiB)
crc32c-2.8-cp313-cp313t-musllinux_1_2_aarch64.whl (78.1KiB)
crc32c-2.8-cp313-cp313t-musllinux_1_2_x86_64.whl (77.2KiB)
crc32c-2.8-cp313-cp313t-win32.whl (63.3KiB)
crc32c-2.8-cp313-cp313t-win_amd64.whl (65.0KiB)
crc32c-2.8-cp314-cp314-macosx_10_13_universal2.whl (64.8KiB)
crc32c-2.8-cp314-cp314-macosx_10_13_x86_64.whl (61.6KiB)
crc32c-2.8-cp314-cp314-macosx_11_0_arm64.whl (60.1KiB)
crc32c-2.8-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (78.3KiB)
crc32c-2.8-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.8KiB)
crc32c-2.8-cp314-cp314-musllinux_1_2_aarch64.whl (78.9KiB)
crc32c-2.8-cp314-cp314-musllinux_1_2_x86_64.whl (78.2KiB)
crc32c-2.8-cp314-cp314-win32.whl (63.4KiB)
crc32c-2.8-cp314-cp314-win_amd64.whl (65.2KiB)
crc32c-2.8-cp314-cp314t-macosx_10_13_universal2.whl (64.6KiB)
crc32c-2.8-cp314-cp314t-macosx_10_13_x86_64.whl (61.5KiB)
crc32c-2.8-cp314-cp314t-macosx_11_0_arm64.whl (60.0KiB)
crc32c-2.8-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (77.3KiB)
crc32c-2.8-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.1KiB)
crc32c-2.8-cp314-cp314t-musllinux_1_2_aarch64.whl (78.1KiB)
crc32c-2.8-cp314-cp314t-musllinux_1_2_x86_64.whl (77.2KiB)
crc32c-2.8-cp314-cp314t-win32.whl (63.3KiB)
crc32c-2.8-cp314-cp314t-win_amd64.whl (65.1KiB)
crc32c-2.8-cp38-cp38-macosx_10_9_universal2.whl (64.5KiB)
crc32c-2.8-cp38-cp38-macosx_10_9_x86_64.whl (61.3KiB)
crc32c-2.8-cp38-cp38-macosx_11_0_arm64.whl (59.8KiB)
crc32c-2.8-cp38-cp38-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (77.6KiB)
crc32c-2.8-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (79.2KiB)
crc32c-2.8-cp38-cp38-musllinux_1_2_aarch64.whl (77.7KiB)
crc32c-2.8-cp38-cp38-musllinux_1_2_x86_64.whl (77.0KiB)
crc32c-2.8-cp38-cp38-win32.whl (63.3KiB)
crc32c-2.8-cp38-cp38-win_amd64.whl (65.0KiB)
crc32c-2.8-cp39-cp39-macosx_10_9_universal2.whl (64.8KiB)
crc32c-2.8-cp39-cp39-macosx_10_9_x86_64.whl (61.5KiB)
crc32c-2.8-cp39-cp39-macosx_11_0_arm64.whl (60.1KiB)
crc32c-2.8-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (77.3KiB)
crc32c-2.8-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (78.9KiB)
crc32c-2.8-cp39-cp39-musllinux_1_2_aarch64.whl (78.0KiB)
crc32c-2.8-cp39-cp39-musllinux_1_2_x86_64.whl (77.2KiB)
crc32c-2.8-cp39-cp39-win32.whl (63.4KiB)
crc32c-2.8-cp39-cp39-win_amd64.whl (65.1KiB)
crc32c-2.8-pp311-pypy311_pp73-macosx_10_15_x86_64.whl (60.9KiB)
crc32c-2.8-pp311-pypy311_pp73-macosx_11_0_arm64.whl (59.8KiB)
crc32c-2.8-pp311-pypy311_pp73-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (62.6KiB)
crc32c-2.8-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (63.3KiB)
crc32c-2.8-pp311-pypy311_pp73-win_amd64.whl (65.1KiB)
crc32c-2.8.tar.gz (47.0KiB)
No dependencies