pycrc
pycrc is a free, easy to use Cyclic Redundancy Check (CRC) calculator and C
source code generator.
Download pycrc below
or fork it on GitHub.
Index ^{¶}
Description ^{¶}
pycrc provides CRC reference implementations in Python and a C
source code generator.
The used CRC variant can be chosen from a fast but spaceconsuming implementation to slower but smaller versions
especially suitable for embedded applications.
The models can be freely chosen, and the collection of CRC models
lists some of the most popular models by name.
The following functions are implemented:
 calculate the checksum of a string or a file.

generate the source files for a
C
implementation.
The following variants of the CRC algorithm are supported:
 bitbybit: the basic algorithm which operates individually on every bit of the augmented message (i.e. the input data with Width zero bits added at the end). This algorithm is a straightforward implementation of the basic polynomial division and is the easiest one to understand, but it is also the slowest one among all possible variants.
 bitbybitfast: a variation of the simple bitbybit algorithm. This algorithm still iterates over every bit of the message, but does not augment it (does not add Width zero bits at the end). It gives the same result as the bitbybit method by carefully choosing the initial value of the algorithm. This method might be a good choice for embedded platforms, where code space is more important than execution speed.
 tabledriven: the standard table driven algorithm. This is the fastest variant because it operates on one byte at a time, as opposed to one bit at the time. This method uses a lookup table (usually of 256 elements), which might not be acceptable for small embedded systems. The number of elements in the lookup table can be reduced with the tableidxwidth command line switch. The value of 4 bits for the table index (16 elements in the lookup table) can be a good compromise between execution speed and code size.
pycrc is released under the terms of the MIT licence.
Documentation ^{¶}
 The Man page is the most comprehensive source of information.
 The Tutorial how to use the generated source code in your program.
 CRC generator documentation of the
C
interface.  List of supported CRC models.
 FAQ Frequently Asked Questions.
Contact ^{¶}
 Subscribe to the pycrcusers Mailing list.
 If you have found a bug or want to request a feature, please submit it to the pycrc Issue Tracker.
 Contact the author at <tehpehweb@tty1.net>.
If you like pycrc and you would like to give something back, then please see some ways how to say thanks.
Download ^{¶}
The latest released version is:
Older versions can be downloaded from the pycrc news archive or from the pycrc git repository on GitHub.
To Do ^{¶}
pycrc is considered stable code. No new features are planned, but bugs are still fixed and new models added on request.
Check out the pycrc issue tracker for open bugs and feature requests.
CRC links ^{¶}
 Ross N. Williams' Painless Guide to CRC Error Detection Algorithms is a very good starting point to understand CRC algorithms.
 The online CRC calculator has been heavily used in the early stage of pycrc. It is a very good place to test your CRC implementation and the
C
implementation on this site is worth studying.  The Wikipediapage on Cyclic redundancy check contains a rather scientific (i.e. dry) explanation of the matter, but the links on the bottom of the page are very useful.
 The Catalogue of parametrised CRC Algorithms by Greg Cook contains a lot of useful information about CRC variants.
 Terry Ritter's The Great CRC Mystery is another good place to study CRC algorithms.
 Sometimes the result of a CRC calculation is known but not the parameters. In that case Gregory Ewing's article ReverseEngineering a CRC Algorithm comes handy. It outlines an algorithm how to get the CRC parameters from raw data. Greg Cook's Perl script CRC RevEng does a good job in finding the parameters from a few data points.
Other Free CRC tools ^{¶}
 crcgenerator is a Python module which calculates the CRC and generates
C
source code. (MIT licence)  CrcMoose is another CRC Python module, able to generate a CRC of arbitrary models and it contains a long list of CRC models. (MIT licence)
 Universal Crc is a
C
program that generates fastC
source code. It is noteworthy that it can generate a tabledriven algorithm for polynomials which do not have to be 8bit aligned. (GPL licence)
The source code for pycrc is on GitHub.