Skip to main content

Library for calculating CRC4/CRC8/CRC16/CRC32/CRC64

Project description

libscrc is a library for calculating CRC4 CRC5 CRC6 CRC7 CRC8 CRC16 CRC32 CRC64.

CRCx

CRC8

CRC16

CRC32

CRC64

CRC4-ITU

INTEL

MODBUS

FSC

ISO

CRC5-ITU

BCC

IBM

CRC32

ECMA182

CRC5-EPC

LRC

XModem

MPEG2

CRC5-USB

MAXIM8

CCITT

ADLER32

CRC6-ITU

ROHC

KERMIT

FLETCHER32

CRC7-MMC

ITU8

MCRF4XX

CRC8

SICK

SUM8

DNP

FLETCHER8

X25

USB

MAXIM16

DECT

TCP

UDP

FLETCHER16

EPC16

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.

  • Cross compile and install the library:

    # vim setup.cfg
    universal=1
    plat-name=linux_armv7l
    
    export CROSS_COMPILE=arm-linux-gnueabihf-
    export CC='${CROSS_COMPILE}gcc -pthread'
    export LDSHARED='${CROSS_COMPILE}gcc -shared'
    export CFLAGS='-I/usr/include/python3.5m -I/usr/include/'
    
    python3 setup.py build
    # gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11)
  • After installation you can run unit tests to make sure that the library works fine. Execute:

    python -m libscrc.test.modbus
    python -m libscrc.test.crc64

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

  • CRCx:

    crc4 = libscrc.itu4(b'1234')
    crc5 = libscrc.itu5(b'1234')
    crc5 = libscrc.epc(b'1234')
    crc5 = libscrc.usb5(b'1234')
    crc6 = libscrc.itu6(b'1234')
    crc7 = libscrc.mmc(b'1234')
  • CRC8:

    crc8 = libscrc.intel(b'1234')
    crc8 = libscrc.bcc(b'1234')
    crc8 = libscrc.lrc(b'1234')
    crc8 = libscrc.maxim8(b'1234')
    crc8 = libscrc.rohc(b'1234')
    crc8 = libscrc.itu8(b'1234')
    crc8 = libscrc.crc8(b'1234')
  • CRC16:

    crc16 = libscrc.ibm(b'1234')            # poly=0xA001 (default Reversed)
    crc16 = libscrc.ibm(b'1234', 0x8005)    # poly=0x8005 (Normal)
    crc16 = libscrc.modbus(b'1234')
    crc16 = libscrc.xmodem(b'1234')
    crc16 = libscrc.ccitt(b'1234')
    crc16 = libscrc.ccitt_false(b'1234')
    crc16 = libscrc.kermit(b'1234')
    crc16 = libscrc.mcrf4xx(b'1234')
    crc16 = libscrc.sick(b'1234')
    crc16 = libscrc.dnp(b'1234')
    crc16 = libscrc.x25(b'1234')
    crc16 = libscrc.usb16(b'1234')
    crc16 = libscrc.maxim16(b'1234')
    crc16 = libscrc.dect(b'1234')           # poly=0x0589 (Cordless Telephones)
    data  = b'\x45\x00\x00\x3c\x00\x00\x00\x00\x40\x11\x00\x00\xc0\xa8\x2b\xc3\x08\x08\x08\x08\x11'
    crc16 = libscrc.tcp( data )             # 13933
    crc16 = libscrc.udp( data )             # 13933
    
    crc16 = libscrc.epc16(b'123456789')     # RFID EPC(CRC16-PC-EPC)
  • CRC32:

    crc32 = libscrc.fsc(b'1234')            # Ethernet frame sequence (FSC)
    crc32 = libscrc.mpeg2(b'1234')          # MPEG2
    crc32 = libscrc.crc32(b'1234')          # WinRAR, File
  • CRC64:

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

NOTICE

  • v0.1.6+ version will not support python2 series (2020-01-20)

V1.0 (2020-03-23)

  • New hacker8 hacker16 hacker32 hacker64

  • New FLETCHER8 FLETCHER16 FLETCHER32

V0.1.5 (2017-09-22)

  • New CRC4-ITU Poly = 0x03 Initial = 0x00 Xorout=0x00 Refin=True Refout=True

  • New CRC5-ITU Poly = 0x15 Initial = 0x00 Xorout=0x00 Refin=True Refout=True

  • New CRC5-EPC Poly = 0x09 Initial = 0x09 Xorout=0x00 Refin=False Refout=False

  • New CRC5-USB Poly = 0x05 Initial = 0x1F Xorout=0x1F Refin=True Refout=True

  • New CRC6-ITU Poly = 0x03 Initial = 0x00 Xorout=0x00 Refin=True Refout=True

  • New CRC7-MMC Poly = 0x09 Initial = 0x00 Xorout=0x00 Refin=False Refout=False

V0.1.4 (2017-09-21)

  • New CRC8-MAXIM8 Poly = 0x31 Initial = 0x00 Xorout=0x00 Refin=True Refout=True

  • New CRC8-ROHC Poly = 0x07 Initial = 0xFF Xorout=0x00 Refin=True Refout=True

  • New CRC8-ITU Poly = 0x07 Initial = 0x00 Xorout=0x55 Refin=False Refout=False

  • New CRC8-CRC8 Poly = 0x07 Initial = 0x00 Xorout=0x00 Refin=False Refout=False

V0.1.3 (2017-09-19)

  • New CRC16-X25

  • New CRC16-USB

  • New CRC16-MAXIM16

  • New CRC16-CCITT_FALSE

  • New CRC16-DECT

Bugfixes
  • Calculate CRC16-IBM of poly = 0x8005 is ERROR.

V0.1.2 (2017-08-22)

Platform Support
  • Win32

  • Linux_x86_64

  • MacOSX_10_6_intel

  • ARMv7 (Toradex Ixora iMX6 Linux-4.1.41)

Bugfixes
  • Coding C99 standard.

  • Python/C API parsing arguments type error in linux.

V0.1.1 (2017-08-20)

  • New CRC16-NDP and CRC16-SICK

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 Distributions

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

libscrc-1.1-cp38-cp38-win_amd64.whl (59.4 kB view details)

Uploaded CPython 3.8Windows x86-64

libscrc-1.1-cp38-cp38-win32.whl (54.0 kB view details)

Uploaded CPython 3.8Windows x86

libscrc-1.1-cp38-cp38-manylinux1_x86_64.whl (100.6 kB view details)

Uploaded CPython 3.8

libscrc-1.1-cp37-cp37m-win_amd64.whl (59.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

libscrc-1.1-cp37-cp37m-win32.whl (54.0 kB view details)

Uploaded CPython 3.7mWindows x86

libscrc-1.1-cp37-cp37m-manylinux1_x86_64.whl (87.5 kB view details)

Uploaded CPython 3.7m

libscrc-1.1-cp36-cp36m-win_amd64.whl (82.3 kB view details)

Uploaded CPython 3.6mWindows x86-64

libscrc-1.1-cp36-cp36m-win32.whl (101.4 kB view details)

Uploaded CPython 3.6mWindows x86

libscrc-1.1-cp36-cp36m-manylinux1_x86_64.whl (99.9 kB view details)

Uploaded CPython 3.6m

libscrc-1.1-cp35-cp35m-win_amd64.whl (58.2 kB view details)

Uploaded CPython 3.5mWindows x86-64

libscrc-1.1-cp35-cp35m-win32.whl (52.9 kB view details)

Uploaded CPython 3.5mWindows x86

libscrc-1.1-cp27-cp27mu-manylinux1_x86_64.whl (78.9 kB view details)

Uploaded CPython 2.7mu

File details

Details for the file libscrc-1.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: libscrc-1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 59.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1bf836d9b694b17f5cd19ef0b02457b824e9d060b207b2f1c4f94a555b63792e
MD5 b529df5480e44f6721937441c012b707
BLAKE2b-256 29cec998acff317b5f97eaac856d11d2c3479c0966cce4d52298f159adf463ac

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp38-cp38-win32.whl.

File metadata

  • Download URL: libscrc-1.1-cp38-cp38-win32.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 d90570a2fc004de788ed8593ac08bd7fb2dfc84460d466bad4fc618e809d2ce0
MD5 e9470c0529cdd442861e79d746f8106f
BLAKE2b-256 3ba84a982627cdcc354857bac3fa6b8c54f8187bb77cd05f80dc58e94827cc82

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: libscrc-1.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 100.6 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1adb4b8ee1bdc7c309ebdf08ce93adc5fa24c6b283a1c019f4d545d16a6ece5a
MD5 b8f4e94b7d5b5c086fb510d11aa725cd
BLAKE2b-256 a69266dae4b9ab3993407ff4e6ea1a16fd99180fb4b8924e0179c1e234915103

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: libscrc-1.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 59.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c1717c38b1a682b1107da603cc9fdfb45787f276cdd702aa0819aaed325594ff
MD5 9e62b05af28b8b901db699e144c15008
BLAKE2b-256 27f046d4ec6bdabc7418036a033b689ffbac66fd25d9a9e22eb65d316ca1373c

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp37-cp37m-win32.whl.

File metadata

  • Download URL: libscrc-1.1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 0926fdf00906f5c11467bfd2491470aa8da3fb693766b44e08c64cd91701cca1
MD5 60a20f1f9eca51d2dadcee3d40bc0f96
BLAKE2b-256 35f423bebf882a4e6289781a5448a7ff0898fec87fa464aa82dc7cbe7236c6c5

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: libscrc-1.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 87.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 11e044bfb0e4ba0f673fdd27325e17f0d55630b772f7bedc94579314e65f1445
MD5 b97a095e8cd8651640c897f0ca70bfb8
BLAKE2b-256 416e1f17ed750da4a4063563538a4eedfea4e38e9eef67f588ca53aa33881d2b

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: libscrc-1.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 82.3 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1c9d7d2054e06e74d9a0bccd4a622b79572c4a04ea2f08f6bb5c349bf6112518
MD5 20340e2eacb3fb2af54da55d0294ea04
BLAKE2b-256 e4d112cce9fb27634de45ea622109eb7c7d8b5bc1c4386e20c2e2275f9531c0e

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp36-cp36m-win32.whl.

File metadata

  • Download URL: libscrc-1.1-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 101.4 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.5

File hashes

Hashes for libscrc-1.1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 373d96ce28deef38a9fad72bdd3b2944200a5e7048e324b5995f631c4da0368e
MD5 eb8985a7bcb8fee29ed396520677dd4c
BLAKE2b-256 652dfc0b9463b2f90b87de65599a11090bb7319d4147e4b573a8db853e6ad79e

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: libscrc-1.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 99.9 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b6f8d5365a3fad66ce19bcd4af79c2b70da17d6814f4774480bc7b748e42f02a
MD5 75f147157d6bcd95938163457627fcf4
BLAKE2b-256 6f8c894a96fb78562774e1eaf5648f8ba957b2ee1ed566fc2e0a39b8da3db5e7

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: libscrc-1.1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 58.2 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.5

File hashes

Hashes for libscrc-1.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 7c5471744a9db909f138d42bc08dba1764f1190fb508ef672399403c617196fd
MD5 cc341e3741d4fc280132c899e22857a9
BLAKE2b-256 06a81d4ef1d3739c203c5edb1f9a7ed61d7e222f1e978c84a901eb6f06efac0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-1.1-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 52.9 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 e94a8575028c5aee18fb8b5cb19d74c179548b2ba49ec2d515e6ecf49b1fc1b3
MD5 f4ca52e24040a8a628b1caeeebe7a46c
BLAKE2b-256 6614a88562890261c6533a9b028fdb187c2ee1b361ec12dad5c1ddf30a14e374

See more details on using hashes here.

File details

Details for the file libscrc-1.1-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: libscrc-1.1-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 78.9 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for libscrc-1.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6f1d32ee93f81540522e639a7ec20743050666278443b5e649aa31e494d7789e
MD5 982210c5ee009189c8352adbd5d597d2
BLAKE2b-256 5a11dc37ad0fecab27df76eec4112656e8f72325c341ab452e9e4d462423dfd4

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