Skip to main content

Python library for calculating CRC16

CRC is a way of detecting accidental changes in data storage or transmission. There are many variants of CRC and CRC16, in particular. This library calculates only CRC16 (16-bit codes) and the only supported variant at the moment is CRC-CCITT (XModem).

If you want to know more about CRC, http://wikipedia.org/wiki/Cyclic_redundancy_check is a good place to start.

If you want other variants of CRC16 supported, please make a request at http://code.google.com/p/pycrc16/issues

Source codes are hosted at https://github.com/gennady/pycrc16 If you want to contribute to this library, create a fork, make you changes and then create a pull request. Any help is appreciated.

Installation

On Windows you can use precompiled binaries which can be found at http://code.google.com/p/pycrc16/downloads

On Linux and other operation systems you should compile the library from the source codes. To do this on Linux use following steps:

  • download source tarball, e.g. crc16-0.1.1.tar.gz, from http://code.google.com/p/pycrc16/downloads

  • extract it with command:

    tar -xzf crc16-0.1.1.tar.gz
  • compile and install the library:

    cd crc16-0.1.1
    python setup.py build
    sudo python setup.py install

    you will need the administrative privileges to execute the last command.

After installation you can run unit tests to make sure that the library works fine. Execute:

python -m crc16.test

Usage

In Python 3:

import crc16
print(crc16.crc16xmodem(b'123456789'))

In Python 2 you should use strings instead of binary data:

import crc16
print(crc16.crc16xmodem('123456789'))

You can also calculate CRC gradually:

import crc16
crc = crc16.crc16xmodem(b'1234')
crc = crc16.crc16xmodem(b'56789', crc)
print(crc)

Other projects

There are a number of projects and libraries for CRC calculation. See for example:

Metadata

Release files for pycrc16 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycrc16 0.1.2
File Size Uploaded
pycrc16-0.1.2.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycrc16 0.1.2
File Interpreter ABI Platform
pycrc16-0.1.2-cp310-cp310-macosx_12_0_arm64.whl CPython 3.10 CPython 3.10 macOS 12.0+ ARM64 Details

Total release size: 22.2 kB

Release files / pycrc16-0.1.2.tar.gz

Download URL pycrc16-0.1.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fe1a03d92b352669baa4f7376392674e96f1e47a9c520dae3d0cd522c8c3b744
BLAKE2b-256 checksum
How to use checksums
b475816874cdc473c1d3a6a491e12f93fe40839fc0f349c712fa927d314fa12e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release files / pycrc16-0.1.2-cp310-cp310-macosx_12_0_arm64.whl

Download URL pycrc16-0.1.2-cp310-cp310-macosx_12_0_arm64.whl
Size 11.4 kB
Tags CPython 3.10 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
4d9268382ded070b3c454dfcb2d70aca45ffff84b4089e284c0fc1f5d01f6b25
BLAKE2b-256 checksum
How to use checksums
0011a3a3ddd6c55886d900e6f184c617472e6dfed70bf39575015789f73e848c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page