Python .crc32()
Anonymous contributor
Published Oct 22, 2025
Contribute to Docs
The .crc32() function computes a CRC-32 checksum of the given data using a cyclic redundancy check algorithm. It is commonly used to detect accidental changes in raw data.
Syntax
binascii.crc32(data, value=0)
Parameters:
data: A bytes-like object containing the binary data whose CRC-32 checksum is to be computed.value(optional): An initial CRC value. This can be used to compute cumulative CRCs across multiple data blocks. Default is0.
Return value:
Returns an integer representing the CRC-32 checksum of the input data.
Example
In this example, the CRC-32 checksum of a single string of binary data is computed:
import binascii# Create binary databinary_data = b"hello world"# Compute the CRC-32 checksumchecksum = binascii.crc32(binary_data)print(checksum)
This produces the following output :
222957957
The output value is an unsigned 32-bit integer representing the checksum of the input data.
Codebyte Example
In this example, the CRC-32 checksum is computed incrementally for multiple chunks of data, simulating a real-world file integrity check:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours