pycrc provides a CRC reference implementation 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 implementations suitable especially for embedded applications.
The following functions are implemented:
- generate the checksum of a string
- generate the C header and source files for a client implementation. The algorithm can be chosen from fast but big implementation to slower but smaller implementations suitable especially for embedded applications.
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 algorithm works only on models with multiples of 8 as width. 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) a significant speed-up can be measured with respect to the bit-by-bit algorithms.