Skip to main content

Library for calculating 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

CRC6-ITU

ROHC

Kermit

CRC7-MMC

ITU8

Sick

CRC8

DNP

X25

USB

MAXIM16

DECT

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

  • 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.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)
  • 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')

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-0.1.6-cp38-cp38-win_amd64.whl (54.8 kB view details)

Uploaded CPython 3.8Windows x86-64

libscrc-0.1.6-cp38-cp38-win32.whl (50.9 kB view details)

Uploaded CPython 3.8Windows x86

libscrc-0.1.6-cp38-cp38-manylinux1_x86_64.whl (85.0 kB view details)

Uploaded CPython 3.8

libscrc-0.1.6-cp37-cp37m-win_amd64.whl (54.8 kB view details)

Uploaded CPython 3.7mWindows x86-64

libscrc-0.1.6-cp37-cp37m-win32.whl (51.0 kB view details)

Uploaded CPython 3.7mWindows x86

libscrc-0.1.6-cp37-cp37m-manylinux1_x86_64.whl (71.9 kB view details)

Uploaded CPython 3.7m

libscrc-0.1.6-cp37-cp37m-linux_armv7l.whl (114.5 kB view details)

Uploaded CPython 3.7m

libscrc-0.1.6-cp36-cp36m-win_amd64.whl (77.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

libscrc-0.1.6-cp36-cp36m-win32.whl (47.1 kB view details)

Uploaded CPython 3.6mWindows x86

libscrc-0.1.6-cp36-cp36m-manylinux1_x86_64.whl (82.0 kB view details)

Uploaded CPython 3.6m

libscrc-0.1.6-cp36-cp36m-macosx_10_6_intel.whl (50.1 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

libscrc-0.1.6-cp35-cp35m-win_amd64.whl (51.9 kB view details)

Uploaded CPython 3.5mWindows x86-64

libscrc-0.1.6-cp35-cp35m-win32.whl (47.2 kB view details)

Uploaded CPython 3.5mWindows x86

libscrc-0.1.6-cp27-cp27mu-manylinux1_x86_64.whl (66.9 kB view details)

Uploaded CPython 2.7mu

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 54.8 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for libscrc-0.1.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5c3816f6e7038f784388800bbd2a8b99c472cdf6b0ff023f15714357cbabe487
MD5 5266579d6220bcf0a77108c35089fdce
BLAKE2b-256 f116acfd3baa6cb1cb0b24445e70882fff38730ccc5f5e31400ee0eba092e1e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp38-cp38-win32.whl
  • Upload date:
  • Size: 50.9 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for libscrc-0.1.6-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 86fc479daf949286c0572f3ff85c98a99d2d126352cdc9498d171be7051e6160
MD5 3ae98e9fa60252ad4a090cd244514ab2
BLAKE2b-256 2ce0bce7d08d0e4b75041d98775f88bfdee1eb3ca5392d160a89e0abb930a317

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 85.0 kB
  • Tags: CPython 3.8
  • 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-0.1.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 384c83e7384b9b8e6e2f4317cf96ad099e243c0b3621f798e906cdf6791fec2f
MD5 d40074c93e7af037367117a37c3f0b4a
BLAKE2b-256 266b66d690e7a99414b540186d6ca4b9f3c32e568ff5a6eb0813f87a36f23f54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 54.8 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for libscrc-0.1.6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2f04d40bd902bf7d91caed721396d28a434003880c1d425ebed57339e0781c6e
MD5 c411bb52b96190a38a35eb15fd7caffe
BLAKE2b-256 5a232bb775ae648dddea09880444bb6cb0fb67635bf25ea5cb75469d13faaa89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 51.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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for libscrc-0.1.6-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 33852bd369d9f4c28ecc3d067a8200affc181a32cbb3437baa0ceb710c15a56b
MD5 a972b042e18953c9e991e2fc18308749
BLAKE2b-256 3fed1ff0a6b174d2929213fe76a5907fc3f2555a30ff03fca5eb91fff8e3cdd2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 71.9 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for libscrc-0.1.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0a93de7c8d2a9eb3656dabe09811b4a6e18f6f85ef2fadc2b45a082d3c79514e
MD5 85386d437eabc7753b4f201f8af21b76
BLAKE2b-256 c56797542e56694ad3e8d453dc8ada9a0c32746c3b73b06b172ea98751d0ca53

See more details on using hashes here.

File details

Details for the file libscrc-0.1.6-cp37-cp37m-linux_armv7l.whl.

File metadata

  • Download URL: libscrc-0.1.6-cp37-cp37m-linux_armv7l.whl
  • Upload date:
  • Size: 114.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3

File hashes

Hashes for libscrc-0.1.6-cp37-cp37m-linux_armv7l.whl
Algorithm Hash digest
SHA256 cb99ff67cc6180a635bb2828d3bdf55b220bd46376be054c98a8627103ca9c18
MD5 5b7c570a32a594313d003382bf1537bc
BLAKE2b-256 4c76908ebb81c1eb63c7f7f0b95cf25648149b67e53d71f41538356a5289e713

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 77.7 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for libscrc-0.1.6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 33f46dc17b043ef56714bcbc87daaf5d1d1404ad6d96805e54d28b37a7e46499
MD5 c271ac8f606989d353417ba39dff1cae
BLAKE2b-256 742fb1773104aba96ebfd650f2c33755af1858f944cf1a2034ed493516e32c39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 47.1 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-0.1.6-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 d3d15949f4c697643d96eef394e3e0e532887f7f88d177cd76f5e94aa7c0485a
MD5 2e82e4afffbf7cbc2401481b2c158765
BLAKE2b-256 3ff02c1b7a029c694d93a74763ae49b6fc852001d82ae04ab83d338365360854

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for libscrc-0.1.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9f28e3aca7d405b2e76956a711a359d68ba5fed298c8a947e6cef46078d2c704
MD5 9a2ac54d81cdad6a529ec134e99efe3f
BLAKE2b-256 f822c5fcfa628d22d728dbe32f77e9d3ddd300caef932cf850539678f7095234

See more details on using hashes here.

File details

Details for the file libscrc-0.1.6-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: libscrc-0.1.6-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for libscrc-0.1.6-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 15296d3301cf506e6b4b8d07da24326108e6223604e9ddfa08a0c898b68f7f01
MD5 4dc929bbcb71d1ad7adc9d373c78404e
BLAKE2b-256 099d5120c789a8e34283e9e091de3934a0d558d37fa00b645da9282a86aa092b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 51.9 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-0.1.6-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 307af4fdd07ee6897757cd43ae0b3e26784153418238d1eb05549011e47223e1
MD5 ac4b66461c71b84ea6c244e8c0d911e9
BLAKE2b-256 11ce538131ada1ce537f7af349ee4371bf8bf1709c137bcd5ff57aaa7aa9f171

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 47.2 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.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.5

File hashes

Hashes for libscrc-0.1.6-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 cd94a6b12167d4dbd2a708cec11f6739a2e07c1e8724fd5e61f2db2a65c2e99e
MD5 e0e5d1c2fb94dab0c2b10d1bfb8b94cb
BLAKE2b-256 fc12a820c3aeab704f9e6101797480ef7db12694d8230a0c44a1b35cc6192122

See more details on using hashes here.

File details

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

File metadata

  • Download URL: libscrc-0.1.6-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 66.9 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for libscrc-0.1.6-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e3bc7e562719f8bc4a6cfc309b03a818e85791f4a28b79788b2f544e9684ae18
MD5 750464a1c50e51641ce23aacb8273380
BLAKE2b-256 a50159ac3a487f9a5d625348cc91c3136d685c3a1cfc675bb044101bc14d3ade

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