Package: crcmod
The software in this package is a Python module for generating objects that
compute the Cyclic Redundancy Check (CRC).  There is no attempt in this package
to explain how the CRC works.  There are a number of resources on the web that
give a good explanation of the algorithms.  Just do a Google search for “crc
calculation” and browse till you find what you need.  Another resource can be
found in chapter 20 of the book “Numerical Recipes in C” by Press et. al.This package allows the use of any 8, 16, 24, 32, or 64 bit CRC.  You can
generate a Python function for the selected polynomial or an instance of the
Crc class which provides the same interface as themd5andshamodules
from the Python standard library.  ACrcclass instance can also generate
C/C++ source code that can be used in another application.GuidelinesDocumentation is available from the doc strings.  It is up to you to decide
what polynomials to use in your application.  If someone has not specified the
polynomials to use, you will need to do some research to find one suitable for
your application.  Examples are available in the unit test scripttest.py.
You may also use thepredefinedmodule to select one of the standard
polynomials.If you need to generate code for another language, I suggest you subclass theCrcclass and replace the methodgenerateCode.  UsegenerateCodeas
a model for the new version.DependenciesPython VersionThe package has separate code to support the 2.x and 3.x Python series.For the 2.x versions of Python, these versions have been tested:2.42.52.62.7It may still work on earlier versions of Python 2.x, but these have not been
recently tested.For the 3.x versions of Python, these versions have been tested:3.1Building C extensionTo build the C extension, the appropriate compiler tools for your platform must
be installed. Refer to the Python documentation for building C extensions for
details.InstallationThe crcmod package is installed usingdistutils.
Run the following command:python setup.py installIf the extension module builds, it will be installed.  Otherwise, the
installation will include the pure Python version.  This will run significantly
slower than the extension module but will allow the package to be used.For Windows users who want to use the mingw32 compiler, run this command:python setup.py build --compiler=mingw32 installFor Python 3.x, the install process is the same but you need to use the 3.x
interpreter.Unit TestingThecrcmodpackage has a modulecrcmod.test, which contains unit
tests for bothcrcmodandcrcmod.predefined.When you first installcrcmod, you should run the unit tests to make sure
everything is installed properly.  The test script performs a number of tests
including a comparison to the direct method which uses a class implementing
polynomials over the integers mod 2.To run the unit tests on Python >=2.5:python -m crcmod.testAlternatively, in thetestdirectory run:python test_crcmod.pyCode GenerationThe crcmod package is capable of generating C functions that can be compiled
with a C or C++ compiler.  In the test directory, there is an examples.py
script that demonstrates how to use the code generator.  The result of this is
written out to the fileexamples.c.  The generated code was checked to make
sure it compiles with the GCC compiler.LicenseThecrcmodpackage is released under the MIT license. See theLICENSEfile for details.ContributorsCraig McQueen