Module liba.crc16
16-bit Cyclic Redundancy Check
Functions
new (poly, reversed) | constructor for 16-bit Cyclic Redundancy Check |
gen (ctx, poly, reversed) | generate for 16-bit Cyclic Redundancy Check |
eval (ctx, block, value) | calculate for 16-bit Cyclic Redundancy Check |
pack (ctx, block, value) | pack a block and its 16-bit Cyclic Redundancy Check value |
Functions
- new (poly, reversed)
-
constructor for 16-bit Cyclic Redundancy Check
Parameters:
- poly integer polynomial that is CRC's divisor
- reversed boolean whether or not to reverse
Returns:
-
a.crc16
16-bit Cyclic Redundancy Check userdata
- gen (ctx, poly, reversed)
-
generate for 16-bit Cyclic Redundancy Check
Parameters:
- ctx a.crc16 16-bit Cyclic Redundancy Check userdata
- poly integer polynomial that is CRC's divisor
- reversed boolean whether or not to reverse
Returns:
-
a.crc16
16-bit Cyclic Redundancy Check userdata
- eval (ctx, block, value)
-
calculate for 16-bit Cyclic Redundancy Check
Parameters:
- ctx a.crc16 16-bit Cyclic Redundancy Check userdata
- block string block to be processed
- value integer initial value
Returns:
-
integer
output value
- pack (ctx, block, value)
-
pack a block and its 16-bit Cyclic Redundancy Check value
Parameters:
- ctx a.crc16 16-bit Cyclic Redundancy Check userdata
- block string block to be processed
- value integer initial value
Returns:
-
string
packed block