Skip to main content

Library for calculating CRC8/CRC16/CRC32/CRC64

Project description

libscrc is a library for calculating CRC8 CRC16 CRC32 CRC64.

CRC8

CRC16

CRC32

CRC64

Intel

Modbus

FSC

ISO

BCC

IBM

FILE

ECMA182

LRC

XModem

CCITT

Kermit

Sick

DNP

Installation

  • Compile and install the library:

    pip3 install libscrc

    or:

    python setup.py build
    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 libscrc.testmodbus
    python -m libscrc.testcrc64

Usage

In Python 3:

import libscrc
crc16 = libscrc.modbus(b'1234')  # Calculate ASCII of modbus
crc16 = libscrc.modbus(b'\x01\x02')  # Calculate HEX of modbus

You can also calculate CRC gradually:

import libscrc
crc16 = libscrc.xmodem(b'1234')
crc16 = libscrc.xmodem(b'5678', crc16)

Example

  • CRC8:

    crc8 = libscrc.intel(b'1234')
    crc8 = libscrc.bcc(b'1234')
    crc8 = libscrc.lrc(b'1234')
    crc8 = libscrc.verb(b'1234')
  • CRC16:

    crc16 = libscrc.ibm(b'1234')
    crc16 = libscrc.modbus(b'1234')
    crc16 = libscrc.xmodem(b'1234')
    crc16 = libscrc.ccitt(b'1234', 0xFFFF)  # poly=0x1021 initvalue=0xFFFF or 0x1D0F
    crc16 = libscrc.kermit(b'1234')
    crc16 = libscrc.sick(b'1234')
    crc16 = libscrc.dnp(b'1234')
  • CRC32:

    crc32 = libscrc.fsc(b'1234')
    crc32 = libscrc.crc32(b'1234')
  • CRC64:

    crc64 = libscrc.iso(b'1234')
    crc64 = libscrc.ecma182(b'1234')

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libscrc-0.1.0-cp35-cp35m-win32.whl (26.6 kB view details)

Uploaded CPython 3.5mWindows x86

File details

Details for the file libscrc-0.1.0-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for libscrc-0.1.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 cdcef8c95b4a612b287fa017f1fa2977368e742720158c32965636891c5cd218
MD5 e2c176476e4a423669c4e2227e0ba919
BLAKE2b-256 fee7cd382199a910683781fce545bda977dd784fabf766f61d2d4383127a3d35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page