crc v0.5.1 CRC

This module is used to calculate CRC (Cyclic Redundancy Check) values for binary data. It uses NIF functions written in C to interate over the given binary calculating the CRC checksum value.

CRC implementations have been tested against these online calculators to validate their correctness to the best of our ability.

https://www.lammertbies.nl/comm/info/crc-calculation.html http://www.sunshine2k.de/coding/javascript/crc/crc_js.html

Summary

Functions

Calculates a 16-bit CCITT CRC with the given seed, seed defaults to 0xFFFF if one is not given

Calculates a 16-bit CCITT 0x1D0F CRC

Calculates a 16-bit CCITT XMODEM CRC

Calculates an XOR checksum for the given binary

Calculates a 16-bit ANSI CRC checksum for the provided binary

Calculates a 16-bit modbus CRC

Calculates a 8-bit CRC with polynomial x^8+x^6+x^3+x^2+1, 0x14D. Chosen based on Koopman, et al. (0xA6 in his notation = 0x14D >> 1): http://www.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf

Initilizes the module by loading NIFs

Functions

ccitt_16(arg, seed \\ 65535)

Specs

ccitt_16(binary, number) :: number

Calculates a 16-bit CCITT CRC with the given seed, seed defaults to 0xFFFF if one is not given.

This CCIT method uses a 0x1021 polynomial.

ccitt_16_1D0F(arg)

Specs

ccitt_16_1D0F(binary) :: number

Calculates a 16-bit CCITT 0x1D0F CRC

This CCIT method uses a 0x1021 polynomial.

ccitt_16_xmodem(arg)

Specs

ccitt_16_xmodem(binary) :: number

Calculates a 16-bit CCITT XMODEM CRC

This CCIT method uses a 0x1021 polynomial.

checksum_xor(arg)

Specs

checksum_xor(binary) :: number

Calculates an XOR checksum for the given binary

crc_16(arg)

Specs

crc_16(binary) :: number

Calculates a 16-bit ANSI CRC checksum for the provided binary

crc_16_modbus(arg)

Specs

crc_16_modbus(binary) :: number

Calculates a 16-bit modbus CRC

crc_8(arg, seed \\ 255)

Specs

crc_8(binary, number) :: number

Calculates a 8-bit CRC with polynomial x^8+x^6+x^3+x^2+1, 0x14D. Chosen based on Koopman, et al. (0xA6 in his notation = 0x14D >> 1): http://www.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf

seed defaults to 0xFF if one is not given

init()

Initilizes the module by loading NIFs