pycrc
pycrc is a free, easy to use Cyclic Redundancy Check (CRC) calculator and source code generator.
Index ¶
Description ¶
pycrc provides CRC reference implementations in Python and a source code generator for C.
The used CRC variant can be chosen from a fast but space-consuming implementation to slower but smaller versions
especially suitable for embedded applications.
The models can be freely chosen, but a comprehensive collection of CRC models
is available 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:
-
bit-by-bit: the basic algorithm which operates individually on every bit of the augmented message
(i.e. the input data with width 0-bits attached to the end).
This algorithm is the easiest one to understand, because it's a direct implementation of the basic polynomial division,
but it is also the slowest among all possible variants.
-
bit-by-bit-fast: a variation of the simple bit-by-bit algorithm,
which doesn't need the augmented message.
This algorithm might be a good choice for embedded platforms, where code space is a major concern.
-
table-driven: the standard table driven algorithm.
This is the fastest variant, because it operates on bytes as opposed to bits, and uses a look-up table of 256 elements, which might
not be feasible for small embedded systems, though. Anyway, the number of elements in the look-up table can be reduced by means of
the --table_idx_with command line switch.
By using 4 bits (16 elements in the look-up table) the code is still very fast (roughly half the speed of a 8-bit table-driven code)
but much more compact.
pycrc is released under the terms of the MIT licence.
Documentation ¶
Download ¶
Older versions can be downloaded from sourceforge.net.
Or fork pycrc on GitHub
(using https protocol https://github.com/tpircher/pycrc.git
or git protocol git://github.com/tpircher/pycrc.git).
News ¶
Version 0.7.9 released
(08 December 2011)
Version 0.7.9 is a minor bugfix release.
- Fixed a bug in the generated C89 code that included stdint.h. (This time for real!)
- Fixed a bug in the generated C89 code when using a 64 bit CRC.
- The --verbose option made pycrc quit without error message.
pycrc repository on GitHub
(01 November 2011)
pycrc has now a
repository on GitHub.
Feel free to fork and to contribute back!
Version 0.7.8 released
(10 July 2011)
Version 0.7.8 is a minor bugfix release.
- The C99 header file stdint.h is no more included in C89/ANSI code.
- Found a more helpful name of the included pycrc header file when generating C code to stdout. Thanks to Lorenzo Cappelletti.
- Removed an unused variable in the option parser.
All news can be read in the pycrc news archive.
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 pycrc's issue tracker for other open bugs and feature requests.
Who uses pycrc ¶
Companies or organisations that use pycrc are:
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 WikiPedia-page 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 Parameterised 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 Reverse-Engineering a CRC Algorithm comes handy. It outlines an algorithm how to get the CRC parameters from raw data. Greg Cook's Perl script crcbfs.pl does a good job in finding the parameters from a few data points.
- crc-generator 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 fast C source code. It is noteworthy that it can generate a table-driven algorithm for polynoms which do not have to be 8-bit aligned. (GPL licence)
