- crc = cipher.crc8(s [, i [, j [, start]]])
- crc = cipher.crc16(s [, i [, j [, start]]])
- crc = cipher.crc32(s [, i [, j [, start]]])
SYNOPSIS
DESCRIPTION
Calculate the CRC (cyclic redundancy check) of the characters s[i],
s[i+1], ···, s[j].
The default value for i is 1;
the default value for j is the number of characters in s.
The functions calculate an 8-bit (Dallas/Maxim, polynome 0x31), 16-bit (CRC-CCITT, polynome 0x1021) or 32-bit (Ethernet, polynome 0x4C11DB7) CRC value, respectively.
If not explicitly specified, the CRC calculation starts with all bits set to 1 (0xFF, 0xFFFF or
0xFFFFFFFF).
(You can pass nil for i and/or j if you only want to
pass a different start value.)
RETURN VALUE
An integer number.
EXAMPLE
>
print(string.format("%04X", cipher.crc16(string.fromhex("880D0800FEDF04000110000000"))))
630E
>
print(string.format("%04X", cipher.crc16(string.fromhex("880D0800FEDF0400011000630E"))))
0000