.. image:: https://img.shields.io/pypi/v/crcengine.svg
:target: https://pypi.python.org/pypi/crcengine
.. image:: https://img.shields.io/github/actions/workflow/status/GardenTools/CrcEngine/python-package.yml
:target: https://github.com/GardenTools/CrcEngine/actions?query=branch%3Amaster
.. image:: https://img.shields.io/pypi/pyversions/CrcEngine.svg
:target: https://pypi.python.org/pypi/crcengine
.. image:: https://img.shields.io/pypi/format/CrcEngine.svg
:target: https://pypi.python.org/pypi/crcengine
.. image:: https://readthedocs.org/projects/crcengine/badge/?version=latest
:target: https://crcengine.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
==========
CrcEngine
==========
A python library for CRC calculation providing table-based as well as
bit-bashing implementations (for reference).
* Free software: GNU General Public License v3
* Documentation: https://crcengine.readthedocs.io.
Installing
----------
CrcEngine can be installing using pip with
.. code-block:: python
pip install crcengine
Usage
-----
Pre-defined algorithms such as CRC32 are available. Tailored algorithms can
be created by calling CrcEngine.create() and other related methods.
A calculation engine for a specific named algorithm can be obtained using
CrcEngine.new(). Algorithms which are not pre-defined can be created using
CrcEngine.create()
A list of pre-defined algorithms can be obtained using crcengine.algorithms_available()
.. code-block:: python
>>> list(crcengine.algorithms_available())
['crc8', 'crc8-autosar', 'crc8-bluetooth', 'crc8-ccitt', 'crc8-gsm-b', 'crc8-sae-j1850', 'crc15-can', 'crc16-kermit', 'crc16-ccitt-true', 'crc16-xmodem', 'crc16-autosar', 'crc16-ccitt-false', 'crc16-cdma2000', 'crc16-ibm', 'crc16-modbus', 'crc16-profibus', 'crc24-flexray16-a', 'crc24-flexray16-b', 'crc32', 'crc32-bzip2', 'crc32-c', 'crc64-ecma']
Built-in algorithms
~~~~~~~~~~~~~~~~~~~
crc8, crc8-autosar, crc8-bluetooth, crc8-ccitt, crc8-gsm-b, crc8-sae-j1850, crc15-can, crc16-kermit, crc16-ccitt-true, crc16-xmodem, crc16-autosar, crc16-ccitt-false, crc16-cdma2000, crc16-ibm, crc16-modbus, crc16-profibus, crc24-flexray16-a, crc24-flexray16-b, crc32, crc32-bzip2, crc32-c, crc64-ecma
Examples
--------
Using a pre-defined algorithm
.. code-block:: python
import crcengine
crc_algorithm = crcengine.new('crc32-bzip2')
result = crc_algorithm(b'123456789')
print('CRC=0x{:08x}'.format(result))
Output:
> CRC=0xfc891918
Defining an algorithm
.. code-block:: python
import crcengine
params = crcengine.CrcParams(0x864cfb, 24, 0xb704ce, reflect_in=False, reflect_out=False, xor_out=0)
crc_openpgp = crcengine.create_from_params(params)
# this is equivalent to
crc_openpgp = crcengine.create(params=params)
# invocation
result = crc_openpgp(b'123456789')
print(f'CRC=0x{result:08x}')
When using create() `params` must be passed as a keyword parameter, since the function also accepts polynomial and seed
parameters for backwards compatibility.
Code Generation
---------------
The library can generate C code for a given table-algorithm. The code produced
is intended to be a reasonable compromise between size, complexity and speed
without requiring allocation of memory for table generation at runtime.
Faster implementations of specific algorithms can be achieved in software which
unroll loops and pipeline the operations different bytes to introduce
parallelism in the calculation see intel_soft_src_ for example. Some processors
also include instructions specifically for crc calculation.
.. _intel_soft_src: https://github.com/intel/soft-crc
Code Generation Example usage:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Generating code into a directory named "out" by passing CRC parameters
.. code-block:: python
params = crcengine.get_algorithm_params('crc32')
crcengine.generate_code(params, 'out/')
or referencing the algorithm by name
.. code-block:: python
crcengine.generate_code('crc16-xmodem', 'out/')
Downloading
-----------
- The source is available on github_
- Git clone crcengine.git_
- On pypi.org_
.. _github: https://github.com/GardenTools/crcengine
.. _crcengine.git: https://github.com/GardenTools/crcengine.git
.. _pypi.org: https://pypi.org/project/crcengine/
Running the tests
-------------------------
Tests can be performed directly by executing pytest in the "tests" directory
Running the Codegen tests
-------------------------
The codegen tests make use of ceedling_ which is expected to be installed as a ruby gem.
The unit tests are configured to compile with gcc.
.. _ceedling: https://github.com/ThrowTheSwitch/Ceedling
-------
With thanks to Greg Cook for providing such a thoroughly collated list of
`CRC definitions`_
.. _CRC definitions: http://reveng.sourceforge.net/crc-catalogue/all.htm
Raw data
{
"_id": null,
"home_page": "https://github.com/GardenTools/crcengine",
"name": "crcengine",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.2,<4.0.0",
"maintainer_email": "",
"keywords": "crcengine,CRC,cyclic,redundancy,check,checksum,code-generation,Castagnoli,CRC32,CRC16-CCITT",
"author": "Garden Tools",
"author_email": "gardensofdorwinion@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/10/78/6369a058f50319e54fdabadf9a8fa44cd69aef4afa64519e8240b886217b/crcengine-0.4.0.post1.tar.gz",
"platform": null,
"description": ".. image:: https://img.shields.io/pypi/v/crcengine.svg\n :target: https://pypi.python.org/pypi/crcengine\n\n.. image:: https://img.shields.io/github/actions/workflow/status/GardenTools/CrcEngine/python-package.yml\n :target: https://github.com/GardenTools/CrcEngine/actions?query=branch%3Amaster\n\n.. image:: https://img.shields.io/pypi/pyversions/CrcEngine.svg\n :target: https://pypi.python.org/pypi/crcengine\n\n.. image:: https://img.shields.io/pypi/format/CrcEngine.svg\n :target: https://pypi.python.org/pypi/crcengine\n\n.. image:: https://readthedocs.org/projects/crcengine/badge/?version=latest\n :target: https://crcengine.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n==========\nCrcEngine\n==========\nA python library for CRC calculation providing table-based as well as\nbit-bashing implementations (for reference).\n\n* Free software: GNU General Public License v3\n* Documentation: https://crcengine.readthedocs.io.\n\nInstalling\n----------\nCrcEngine can be installing using pip with\n\n.. code-block:: python\n\n pip install crcengine\n\nUsage\n-----\nPre-defined algorithms such as CRC32 are available. Tailored algorithms can\nbe created by calling CrcEngine.create() and other related methods.\n\nA calculation engine for a specific named algorithm can be obtained using\nCrcEngine.new(). Algorithms which are not pre-defined can be created using\nCrcEngine.create() \n\nA list of pre-defined algorithms can be obtained using crcengine.algorithms_available()\n\n.. code-block:: python\n\n >>> list(crcengine.algorithms_available())\n ['crc8', 'crc8-autosar', 'crc8-bluetooth', 'crc8-ccitt', 'crc8-gsm-b', 'crc8-sae-j1850', 'crc15-can', 'crc16-kermit', 'crc16-ccitt-true', 'crc16-xmodem', 'crc16-autosar', 'crc16-ccitt-false', 'crc16-cdma2000', 'crc16-ibm', 'crc16-modbus', 'crc16-profibus', 'crc24-flexray16-a', 'crc24-flexray16-b', 'crc32', 'crc32-bzip2', 'crc32-c', 'crc64-ecma']\n\n\nBuilt-in algorithms\n~~~~~~~~~~~~~~~~~~~\ncrc8, crc8-autosar, crc8-bluetooth, crc8-ccitt, crc8-gsm-b, crc8-sae-j1850, crc15-can, crc16-kermit, crc16-ccitt-true, crc16-xmodem, crc16-autosar, crc16-ccitt-false, crc16-cdma2000, crc16-ibm, crc16-modbus, crc16-profibus, crc24-flexray16-a, crc24-flexray16-b, crc32, crc32-bzip2, crc32-c, crc64-ecma\n\nExamples\n--------\nUsing a pre-defined algorithm\n\n.. code-block:: python\n\n import crcengine\n crc_algorithm = crcengine.new('crc32-bzip2')\n result = crc_algorithm(b'123456789')\n print('CRC=0x{:08x}'.format(result))\n\nOutput:\n> CRC=0xfc891918\n\nDefining an algorithm\n\n.. code-block:: python\n\n import crcengine\n params = crcengine.CrcParams(0x864cfb, 24, 0xb704ce, reflect_in=False, reflect_out=False, xor_out=0)\n crc_openpgp = crcengine.create_from_params(params)\n # this is equivalent to\n crc_openpgp = crcengine.create(params=params)\n # invocation\n result = crc_openpgp(b'123456789')\n print(f'CRC=0x{result:08x}')\n\nWhen using create() `params` must be passed as a keyword parameter, since the function also accepts polynomial and seed\nparameters for backwards compatibility.\n\nCode Generation\n---------------\nThe library can generate C code for a given table-algorithm. The code produced\nis intended to be a reasonable compromise between size, complexity and speed\nwithout requiring allocation of memory for table generation at runtime.\n\nFaster implementations of specific algorithms can be achieved in software which\nunroll loops and pipeline the operations different bytes to introduce\nparallelism in the calculation see intel_soft_src_ for example. Some processors\nalso include instructions specifically for crc calculation.\n\n.. _intel_soft_src: https://github.com/intel/soft-crc\n\nCode Generation Example usage:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nGenerating code into a directory named \"out\" by passing CRC parameters\n\n.. code-block:: python\n\n params = crcengine.get_algorithm_params('crc32')\n crcengine.generate_code(params, 'out/')\n\nor referencing the algorithm by name\n\n.. code-block:: python\n\n crcengine.generate_code('crc16-xmodem', 'out/')\n\n\nDownloading\n-----------\n- The source is available on github_\n- Git clone crcengine.git_\n- On pypi.org_\n\n.. _github: https://github.com/GardenTools/crcengine\n.. _crcengine.git: https://github.com/GardenTools/crcengine.git\n.. _pypi.org: https://pypi.org/project/crcengine/\n\nRunning the tests\n-------------------------\nTests can be performed directly by executing pytest in the \"tests\" directory\n\nRunning the Codegen tests\n-------------------------\nThe codegen tests make use of ceedling_ which is expected to be installed as a ruby gem.\nThe unit tests are configured to compile with gcc.\n\n.. _ceedling: https://github.com/ThrowTheSwitch/Ceedling\n\n-------\n\nWith thanks to Greg Cook for providing such a thoroughly collated list of\n`CRC definitions`_\n\n.. _CRC definitions: http://reveng.sourceforge.net/crc-catalogue/all.htm\n\n",
"bugtrack_url": null,
"license": "GPL-3.0-only",
"summary": "A library for CRC calculation and code generation",
"version": "0.4.0.post1",
"split_keywords": [
"crcengine",
"crc",
"cyclic",
"redundancy",
"check",
"checksum",
"code-generation",
"castagnoli",
"crc32",
"crc16-ccitt"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "88574fddb77d87163862e78933ebb097292cbdf3ca91475a788c9f33d5d21323",
"md5": "cb1a72ed41b8ffc10c14b82f89d899ef",
"sha256": "422c0ba6c7c0ef172fed41f2888b24ded27cb8a767baf42b265b3b5eea77bb7b"
},
"downloads": -1,
"filename": "crcengine-0.4.0.post1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cb1a72ed41b8ffc10c14b82f89d899ef",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.2,<4.0.0",
"size": 40470,
"upload_time": "2023-04-16T20:50:21",
"upload_time_iso_8601": "2023-04-16T20:50:21.234998Z",
"url": "https://files.pythonhosted.org/packages/88/57/4fddb77d87163862e78933ebb097292cbdf3ca91475a788c9f33d5d21323/crcengine-0.4.0.post1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "10786369a058f50319e54fdabadf9a8fa44cd69aef4afa64519e8240b886217b",
"md5": "6342b930c754321a41d8529a4e4817fc",
"sha256": "6dd0640dcb27692299f1156bcae9061e8ec4f7a90fec7c0d882a2ee4544a8eb0"
},
"downloads": -1,
"filename": "crcengine-0.4.0.post1.tar.gz",
"has_sig": false,
"md5_digest": "6342b930c754321a41d8529a4e4817fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.2,<4.0.0",
"size": 31230,
"upload_time": "2023-04-16T20:50:23",
"upload_time_iso_8601": "2023-04-16T20:50:23.172578Z",
"url": "https://files.pythonhosted.org/packages/10/78/6369a058f50319e54fdabadf9a8fa44cd69aef4afa64519e8240b886217b/crcengine-0.4.0.post1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-16 20:50:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "GardenTools",
"github_project": "crcengine",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "crcengine"
}