Skip to main content

A library for CRC calculation

Project description

https://img.shields.io/pypi/v/crcengine.svg https://travis-ci.com/GardenTools/CrcEngine.svg?branch=master Documentation Status Updates

CrcEngine

A python library for CRC calculation providing table-based as well as bit-bashing implementations (for reference).

Usage

Use 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()

Examples

Using a pre-defined algorithm

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

import crcengine
crc_openpgp = crcengine.create(0x864cfb, 24, 0xb704ce, ref_in=False,
                               ref_out=False, xor_out=0, name='crc-24-openpgp')

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 achived 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.

Downloading


With thanks to Greg Cook for providing such a thoroughly collated list of CRC definitions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for crcengine, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size crcengine-0.1.1-py3-none-any.whl (25.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size crcengine-0.1.1.tar.gz (37.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page