DESCRIPTION.rst 3.8 KB

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