CRCx


NameCRCx JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/technikian/crc
SummaryExtensive CRC
upload_time2023-02-04 14:15:21
maintainer
docs_urlNone
authortechnician
requires_python
licenseMPL
keywords python crcx crc cyclic redundancy check checksum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. image:: https://img.shields.io/pypi/v/CRCx.svg
	:target: https://pypi.python.org/pypi/CRCx

.. image:: https://img.shields.io/pypi/l/CRCx
	:target: https://spdx.org/licenses/MPL-2.0.html

.. image:: https://img.shields.io/pypi/pyversions/CRCx.svg
	:target: https://pypi.python.org/pypi/CRCx


CRCx
=======

Extensive Cyclic Redundancy Check

Work in progress...

Examples
----------

..
	Because GitHub doesn't support the include directive the source of
	scripts/examples/simple_tcp_server.py has been copied to this file.

.. code:: python

	import crc_rc3 as crc
	import crc_rc3.catalog
	import crc_rc3.engines.generic
	import crc_rc3.engines.tableized
	import crc_rc3.tables
	import zlib


	data = b"123456789"
	data_a = b"12345"
	data_b = b"6789"
	check = 0xcbf43926  # crc from crc32 algorithm for the str '123456789


	"""
	simple usage
		select cataloged algorithm
		parse your input data
	"""
	calc = crc.create(crc.catalog.crc_32())
	hash_a = calc.calc(data)


	"""
	calculate from multiple strings of input
		via instantiate object from the calculator class
	"""
	calc = crc.create(crc.catalog.crc_32())
	inst = calc()
	inst.process(data_a)  # process, update
	hash_b = inst.final()  # you can check the result halfway through the calculation
	inst.process(data_b)
	hash_c = inst.final()  # result, final


	# todo check if is big endian
	"""
	if you need the hash in bytes
		big endian
	"""
	# hash_d = calc.calc_bytes(data)
	# or
	# hash_e = inst.final_bytes()


	"""
	create the crc table manually
	"""
	# table for crc32
	table = crc.tables.new_lsbf(0x04c11db7, 32)
	# repr it so you can put in your own code
	print(crc.tables.table_repr(32, 80)(table))


	"""
	define your own parameters
		option to select engine algorithm
	"""
	# params for crc32
	params = crc.new(
		# required
		width=32,
		poly=0x04c11db7,
		init=0xffffffff,
		xorout=0xffffffff,
		refin=True,
		refout=True,
		# optional
		name="crc32",
		aliases=("alias_1", "alias_2"),
		desc="description",
		table=table,  # you can manually insert table here to avoid it being
		#  calculated automatically every time your program starts
	)
	calc = crc.create(params)
	hash_f = calc.calc(data)


	"""
	use a different engine
		tableized is fastest engine but creates a table of 256 values
			this is the default
		generic doesn't create a table, but is slower
	"""
	# engine = crc.engines.generic
	engine = crc.engines.tableized
	calc = crc.create(params, engine)
	hash_g = calc.calc(data)


	"""
	use the engine directly
		no 'convenience objects'
	"""
	# NotImplemented


	"""
	test
	"""
	hashes = check, zlib.crc32(data), hash_a, hash_c, hash_f, hash_g
	assert all(h == check for h in hashes)
	print(hashes)


	if __name__ == '__main__':
		pass



Features
--------

...

* 01: ...

Other featues:

* ...

License
-------

CRCx is licensed under `Mozilla Public License`_.

.. External References:
.. _Advanced Climate Systems: http://www.advancedclimate.nl/
.. _GitHub: https://github.com/AdvancedClimateSystems/uModbus/
.. _MODBUS Application Protocol Specification V1.1b3: http://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf
.. _Mozilla Public License: https://github.com/AdvancedClimateSystems/uModbus/blob/develop/LICENSE
.. _Read the Docs: http://umodbus.readthedocs.org/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/technikian/crc",
    "name": "CRCx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,CRCx,crc,cyclic,redundancy,check,checksum",
    "author": "technician",
    "author_email": "<mail@xxxxxxxx.com>",
    "download_url": "https://files.pythonhosted.org/packages/3a/f2/10452083e3536da099903fe5e433806de21fa7adb30938ad3178f3d18a11/CRCx-0.0.4.tar.gz",
    "platform": null,
    "description": "\r\n.. image:: https://img.shields.io/pypi/v/CRCx.svg\r\n\t:target: https://pypi.python.org/pypi/CRCx\r\n\r\n.. image:: https://img.shields.io/pypi/l/CRCx\r\n\t:target: https://spdx.org/licenses/MPL-2.0.html\r\n\r\n.. image:: https://img.shields.io/pypi/pyversions/CRCx.svg\r\n\t:target: https://pypi.python.org/pypi/CRCx\r\n\r\n\r\nCRCx\r\n=======\r\n\r\nExtensive Cyclic Redundancy Check\r\n\r\nWork in progress...\r\n\r\nExamples\r\n----------\r\n\r\n..\r\n\tBecause GitHub doesn't support the include directive the source of\r\n\tscripts/examples/simple_tcp_server.py has been copied to this file.\r\n\r\n.. code:: python\r\n\r\n\timport crc_rc3 as crc\r\n\timport crc_rc3.catalog\r\n\timport crc_rc3.engines.generic\r\n\timport crc_rc3.engines.tableized\r\n\timport crc_rc3.tables\r\n\timport zlib\r\n\r\n\r\n\tdata = b\"123456789\"\r\n\tdata_a = b\"12345\"\r\n\tdata_b = b\"6789\"\r\n\tcheck = 0xcbf43926  # crc from crc32 algorithm for the str '123456789\r\n\r\n\r\n\t\"\"\"\r\n\tsimple usage\r\n\t\tselect cataloged algorithm\r\n\t\tparse your input data\r\n\t\"\"\"\r\n\tcalc = crc.create(crc.catalog.crc_32())\r\n\thash_a = calc.calc(data)\r\n\r\n\r\n\t\"\"\"\r\n\tcalculate from multiple strings of input\r\n\t\tvia instantiate object from the calculator class\r\n\t\"\"\"\r\n\tcalc = crc.create(crc.catalog.crc_32())\r\n\tinst = calc()\r\n\tinst.process(data_a)  # process, update\r\n\thash_b = inst.final()  # you can check the result halfway through the calculation\r\n\tinst.process(data_b)\r\n\thash_c = inst.final()  # result, final\r\n\r\n\r\n\t# todo check if is big endian\r\n\t\"\"\"\r\n\tif you need the hash in bytes\r\n\t\tbig endian\r\n\t\"\"\"\r\n\t# hash_d = calc.calc_bytes(data)\r\n\t# or\r\n\t# hash_e = inst.final_bytes()\r\n\r\n\r\n\t\"\"\"\r\n\tcreate the crc table manually\r\n\t\"\"\"\r\n\t# table for crc32\r\n\ttable = crc.tables.new_lsbf(0x04c11db7, 32)\r\n\t# repr it so you can put in your own code\r\n\tprint(crc.tables.table_repr(32, 80)(table))\r\n\r\n\r\n\t\"\"\"\r\n\tdefine your own parameters\r\n\t\toption to select engine algorithm\r\n\t\"\"\"\r\n\t# params for crc32\r\n\tparams = crc.new(\r\n\t\t# required\r\n\t\twidth=32,\r\n\t\tpoly=0x04c11db7,\r\n\t\tinit=0xffffffff,\r\n\t\txorout=0xffffffff,\r\n\t\trefin=True,\r\n\t\trefout=True,\r\n\t\t# optional\r\n\t\tname=\"crc32\",\r\n\t\taliases=(\"alias_1\", \"alias_2\"),\r\n\t\tdesc=\"description\",\r\n\t\ttable=table,  # you can manually insert table here to avoid it being\r\n\t\t#  calculated automatically every time your program starts\r\n\t)\r\n\tcalc = crc.create(params)\r\n\thash_f = calc.calc(data)\r\n\r\n\r\n\t\"\"\"\r\n\tuse a different engine\r\n\t\ttableized is fastest engine but creates a table of 256 values\r\n\t\t\tthis is the default\r\n\t\tgeneric doesn't create a table, but is slower\r\n\t\"\"\"\r\n\t# engine = crc.engines.generic\r\n\tengine = crc.engines.tableized\r\n\tcalc = crc.create(params, engine)\r\n\thash_g = calc.calc(data)\r\n\r\n\r\n\t\"\"\"\r\n\tuse the engine directly\r\n\t\tno 'convenience objects'\r\n\t\"\"\"\r\n\t# NotImplemented\r\n\r\n\r\n\t\"\"\"\r\n\ttest\r\n\t\"\"\"\r\n\thashes = check, zlib.crc32(data), hash_a, hash_c, hash_f, hash_g\r\n\tassert all(h == check for h in hashes)\r\n\tprint(hashes)\r\n\r\n\r\n\tif __name__ == '__main__':\r\n\t\tpass\r\n\r\n\r\n\r\nFeatures\r\n--------\r\n\r\n...\r\n\r\n* 01: ...\r\n\r\nOther featues:\r\n\r\n* ...\r\n\r\nLicense\r\n-------\r\n\r\nCRCx is licensed under `Mozilla Public License`_.\r\n\r\n.. External References:\r\n.. _Advanced Climate Systems: http://www.advancedclimate.nl/\r\n.. _GitHub: https://github.com/AdvancedClimateSystems/uModbus/\r\n.. _MODBUS Application Protocol Specification V1.1b3: http://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf\r\n.. _Mozilla Public License: https://github.com/AdvancedClimateSystems/uModbus/blob/develop/LICENSE\r\n.. _Read the Docs: http://umodbus.readthedocs.org/en/latest/\r\n",
    "bugtrack_url": null,
    "license": "MPL",
    "summary": "Extensive CRC",
    "version": "0.0.4",
    "split_keywords": [
        "python",
        "crcx",
        "crc",
        "cyclic",
        "redundancy",
        "check",
        "checksum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "41c037bcc6f616bd6c5418529d10a3bff5dfb7e6b267934a2d461c1b7d39d3c6",
                "md5": "fa3e791f63d9998be1eb95f2bcbf18d3",
                "sha256": "d91919dd04119087932a08d7803767bb4de37171bd0fab9a62e7f4e7079cc09f"
            },
            "downloads": -1,
            "filename": "CRCx-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa3e791f63d9998be1eb95f2bcbf18d3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23643,
            "upload_time": "2023-02-04T14:15:19",
            "upload_time_iso_8601": "2023-02-04T14:15:19.125268Z",
            "url": "https://files.pythonhosted.org/packages/41/c0/37bcc6f616bd6c5418529d10a3bff5dfb7e6b267934a2d461c1b7d39d3c6/CRCx-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3af210452083e3536da099903fe5e433806de21fa7adb30938ad3178f3d18a11",
                "md5": "aa2fc0374904ccdda7cfa05887d6f979",
                "sha256": "ef6ab21bbd818c716837910042c35b52554db3b5c963179fa6bcd6c55e714495"
            },
            "downloads": -1,
            "filename": "CRCx-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "aa2fc0374904ccdda7cfa05887d6f979",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19394,
            "upload_time": "2023-02-04T14:15:21",
            "upload_time_iso_8601": "2023-02-04T14:15:21.011471Z",
            "url": "https://files.pythonhosted.org/packages/3a/f2/10452083e3536da099903fe5e433806de21fa7adb30938ad3178f3d18a11/CRCx-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-04 14:15:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "technikian",
    "github_project": "crc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "crcx"
}
        
Elapsed time: 0.60790s