checksum.CRC16
Object → checksum.CRC8 → checksum.CRC16
The class used to create new CRC-16 checksum calculation instances.
Constructor
CRC16(poly: integer?, init: integer?, ref_in: boolean?, ref_out: boolean?, xor_out: integer?): checksum.CRC16Fields
| Name | Type | Description |
|---|---|---|
DigestSize | integer | The size of the checksum in bytes. = 2 |
Static functions
digest | Calculates the CRC-16 checksum of the specified string. |
MAXIM | The CRC-16 checksum class that uses MAXIM algorithm parameters. |
USB | The CRC-16 checksum class that uses USB algorithm parameters. |
XMODEM | The CRC-16 checksum class that uses XMODEM algorithm parameters. |
#CRC16.digest
function CRC16.digest(raw_str: string, poly?: integer, init?: integer, ref_in?: boolean, ref_out?: boolean, xor_out?: integer): integer
Calculates the CRC-16 checksum of the specified string.
Parameters
| Name | Type | Description |
|---|---|---|
raw_str | string | The string is used to calculate checksum. |
polyoptional | integer | The polynomial is used to calculate checksum. |
initoptional | integer | The initial value is used to calculate checksum. |
ref_inoptional | boolean | Whether to reflect the input data before processing. |
ref_outoptional | boolean | Whether to reflect the output data after processing. |
xor_outoptional | integer | The XOR value is used to calculate checksum. |
Returns
| Type | Name | Description |
|---|---|---|
integer | checksum | The CRC-16 checksum, which is greater or equal to 0, and less than 2^16 (0x10000). |
#CRC16.MAXIM
function CRC16.MAXIM(): checksum.CRC16
The CRC-16 checksum class that uses MAXIM algorithm parameters.
Returns
| Type | Name | Description |
|---|---|---|
checksum.CRC16 | object |
#CRC16.USB
function CRC16.USB(): checksum.CRC16
The CRC-16 checksum class that uses USB algorithm parameters.
Returns
| Type | Name | Description |
|---|---|---|
checksum.CRC16 | object |
#CRC16.XMODEM
function CRC16.XMODEM(): checksum.CRC16
The CRC-16 checksum class that uses XMODEM algorithm parameters.
Returns
| Type | Name | Description |
|---|---|---|
checksum.CRC16 | object |
Methods
digest | Finalizes checksum calculation and returns the resulting checksum. |
update | Updates checksum with the specified string. |
#CRC16:digest
function checksum.CRC16:digest(): integer
Finalizes checksum calculation and returns the resulting checksum.
Returns
| Type | Name | Description |
|---|---|---|
integer | checksum | The final checksum value, which is greater or equal to 0, and less than 2^16 (0x10000). |
#CRC16:update
function checksum.CRC16:update(raw_str: string): checksum.CRC16
Updates checksum with the specified string.
Parameters
| Name | Type | Description |
|---|---|---|
raw_str | string | The string is used to update checksum. |
Returns
| Type | Name | Description |
|---|---|---|
checksum.CRC16 | self |