README
1 ===========================
2 crcmod for Calculating CRCs
3 ===========================
4
5 The software in this package is a Python module for generating objects that
6 compute the Cyclic Redundancy Check (CRC). There is no attempt in this package
7 to explain how the CRC works. There are a number of resources on the web that
8 give a good explanation of the algorithms. Just do a Google search for "crc
9 calculation" and browse till you find what you need. Another resource can be
10 found in chapter 20 of the book "Numerical Recipes in C" by Press et. al.
11
12 This package allows the use of any 8, 16, 24, 32, or 64 bit CRC. You can
13 generate a Python function for the selected polynomial or an instance of the
14 Crc class which provides the same interface as the ``md5`` and ``sha`` modules
15 from the Python standard library. A ``Crc`` class instance can also generate
16 C/C++ source code that can be used in another application.
17
18 ----------
19 Guidelines
20 ----------
21
22 Documentation is available from the doc strings. It is up to you to decide
23 what polynomials to use in your application. If someone has not specified the
24 polynomials to use, you will need to do some research to find one suitable for
25 your application. Examples are available in the unit test script ``test.py``.
26 You may also use the ``predefined`` module to select one of the standard
27 polynomials.
28
29 If you need to generate code for another language, I suggest you subclass the
30 ``Crc`` class and replace the method ``generateCode``. Use ``generateCode`` as
31 a model for the new version.
32
33 ------------
34 Dependencies
35 ------------
36
37 Python Version
38 ^^^^^^^^^^^^^^
39
40 The package has separate code to support the 2.x and 3.x Python series.
41
42 For the 2.x versions of Python, these versions have been tested:
43
44 * 2.4
45 * 2.5
46 * 2.6
47 * 2.7
48
49 It may still work on earlier versions of Python 2.x, but these have not been
50 recently tested.
51
52 For the 3.x versions of Python, these versions have been tested:
53
54 * 3.1
55
56 Building C extension
57 ^^^^^^^^^^^^^^^^^^^^
58
59 To build the C extension, the appropriate compiler tools for your platform must
60 be installed. Refer to the Python documentation for building C extensions for
61 details.
62
63 ------------
64 Installation
65 ------------
66
67 The crcmod package is installed using ``distutils``.
68 Run the following command::
69
70 python setup.py install
71
72 If the extension module builds, it will be installed. Otherwise, the
73 installation will include the pure Python version. This will run significantly
74 slower than the extension module but will allow the package to be used.
75
76 For Windows users who want to use the mingw32 compiler, run this command::
77
78 python setup.py build --compiler=mingw32 install
79
80 For Python 3.x, the install process is the same but you need to use the 3.x
81 interpreter.
82
83 ------------
84 Unit Testing
85 ------------
86
87 The ``crcmod`` package has a module ``crcmod.test``, which contains unit
88 tests for both ``crcmod`` and ``crcmod.predefined``.
89
90 When you first install ``crcmod``, you should run the unit tests to make sure
91 everything is installed properly. The test script performs a number of tests
92 including a comparison to the direct method which uses a class implementing
93 polynomials over the integers mod 2.
94
95 To run the unit tests on Python >=2.5::
96
97 python -m crcmod.test
98
99 Alternatively, in the ``test`` directory run::
100
101 python test_crcmod.py
102
103 ---------------
104 Code Generation
105 ---------------
106
107 The crcmod package is capable of generating C functions that can be compiled
108 with a C or C++ compiler. In the test directory, there is an examples.py
109 script that demonstrates how to use the code generator. The result of this is
110 written out to the file ``examples.c``. The generated code was checked to make
111 sure it compiles with the GCC compiler.
112
113 -------
114 License
115 -------
116
117 The ``crcmod`` package is released under the MIT license. See the ``LICENSE``
118 file for details.
119
120 ------------
121 Contributors
122 ------------
123
124 Craig McQueen
125