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.
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 modbusYou 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for libscrc-0.1.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2454cea286142e3923c52ace95021161440784dfa84b2f1f3ef6f5d7e2a5133b |
|
MD5 | 2bef5b6b51122bd1eb0b358aef9c2476 |
|
BLAKE2b-256 | a742412822c21e6c0f9b4732564e6b9947bb57a822c1e71144ed818b3db05efb |
Hashes for libscrc-0.1.5-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e099f34b9698c6e84ace43f6de8f94d8b67b1dd79c346a2d97a6921b0e606db |
|
MD5 | a28448a80ba518e511b959b53beff374 |
|
BLAKE2b-256 | 5abf2aca592bb825dc016cf5e700f6bd470e2491cf74834c110f7df229000e7d |
Hashes for libscrc-0.1.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 500dcc77f37679e8561fd2a6d07f1013a8df3df1eecf0a6ec31c7eef5bcd258d |
|
MD5 | 0a29143e9dc703a7c6678a1876716fd4 |
|
BLAKE2b-256 | e802e7ce1c7041b1802663ab671c51ca87e1c5566cb2c0e3c3920ad13e848a50 |
Hashes for libscrc-0.1.5-cp37-cp37m-linux_armv6l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db3ef2aa9ace4d28190191bb6b1bd970faeb45953c92a77e76c445b0318fe393 |
|
MD5 | 5af08b27f7d2df987a83ea05ac6df0e2 |
|
BLAKE2b-256 | 0616852f627ef58f633358b357ac8726bb51381baaa3a70dd15476a9e843109b |
Hashes for libscrc-0.1.5-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0459262557861b15019909f350df36bfaf7c9432726d45825116570fa5c6b1d2 |
|
MD5 | d14ad0f93de371e6f7a81853fcd2c123 |
|
BLAKE2b-256 | 1f40a9115bff9f58c7bc93286f0ec867406b7d5c15789b86fbcca407645e8d70 |
Hashes for libscrc-0.1.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2005f9a08dec1535f3d1572b65b8cad64416f0ad8235c1b5a3dc2fc418a08905 |
|
MD5 | 077221d55c8a3805948034cf7dba45e3 |
|
BLAKE2b-256 | 7e8187f7de56f5252d83863b79dd03f87e8cc5142581c1611771eb8fdc373a38 |
Hashes for libscrc-0.1.5-cp36-cp36m-linux_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6a997279e27fc49dc5e768caf7742af800a709fd6e7a317ae1579af91456ed2 |
|
MD5 | a03ac90bc4e5166f4fb91b2762e7c4c4 |
|
BLAKE2b-256 | 91012ec586c27b95db1893459ac2efdbcfab9feac63f024eaa9979c20c2783a5 |
Hashes for libscrc-0.1.5-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccdf105b02208a2a2e5266360320c467acb424e325cf64dd7833e28c319faf7d |
|
MD5 | 797862d24bc15beef2d376d24c88448d |
|
BLAKE2b-256 | 2bac0009d525e266d6a4f369b994a9c39fe251864278c420a10f66aefa4bb8c3 |
Hashes for libscrc-0.1.5-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b12d0beefaa9af2770513dda7e3d9d2eab12a0bf14def8e6e62d804903745ba1 |
|
MD5 | 0fb0f9e15b004f3d68f8426e6e9bbc7e |
|
BLAKE2b-256 | 83594480df3a2d5c0435f6099d2457dc880a01d3ac673f4b4dd97f4e618252c1 |
Hashes for libscrc-0.1.5-cp35-cp35m-linux_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 603b88790fabe1fb2f6f051109a28aa015ec6003b8daf6a2faf4b5d5145f8ed2 |
|
MD5 | b07e11509072b5d59f4c3ecdd1069f64 |
|
BLAKE2b-256 | 3b79760cd6c7734620a09ecacb049481edb7d3653bb56b65e4e6f8d976de7427 |
Hashes for libscrc-0.1.5-cp27-cp27m-linux_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 837379a00256ec47d8a1aeec78a72fb8ddb6e585565f4871d2cbc6bdd7d02e56 |
|
MD5 | 3dd6f77995df6984202c450ed62e050a |
|
BLAKE2b-256 | 51630502f5469150bb5db9ed6bb054d827a4aae3b76a5f9e9d921142758dce54 |