Documentation ¶
Index ¶
- Constants
- Variables
- func Checksum(data []byte, tab *Table) uint16
- func ChecksumCCITT(data []byte) uint16
- func ChecksumCCITTFalse(data []byte) uint16
- func ChecksumIBM(data []byte) uint16
- func ChecksumInverted(data []byte, tab *Table) uint16
- func ChecksumMBus(data []byte) uint16
- func ChecksumSCSI(data []byte) uint16
- func ChecksumXModem(data []byte) uint16
- func Update(crc uint16, tab *Table, p []byte) uint16
- func UpdateInverted(crc uint16, tab *Table, p []byte) uint16
- type Hash16
- type Table
Constants ¶
const ( // IBM is used by Bisync, Modbus, USB, ANSI X3.28, SIA DC-07, ... IBM = 0xA001 IBM_NORMAL = 0x8005 // CCITT is used by X.25, V.41, HDLC FCS, XMODEM, Bluetooth, PACTOR, SD, ... // CCITT forward is 0x8408. Reverse is 0x1021. CCITT = 0x8408 CCITTFalse = 0x1021 // SCSI is used by SCSI SCSI = 0xEDD1 MBUS = 0x3D65 XMODEM = 0x1021 )
Predefined polynomials.
Variables ¶
var CCITTFalseTable = makeBitsReversedTable(CCITTFalse)
CCITTFalseTable is the table for CCITT-FALSE.
var CCITTTable = makeTable(CCITT)
CCITTTable is the table for the CCITT polynomial.
var IBMTable = makeTable(IBM)
IBMTable is the table for the IBM polynomial.
var MBusTable = makeBitsReversedTable(MBUS)
var SCSITable = makeTable(SCSI)
SCSITable is the table for the SCSI polynomial.
var XModemTable = makeBitsReversedTable(XMODEM)
Functions ¶
func Checksum ¶
Checksum returns the CRC-16 checksum of data using the polynomial represented by the Table.
func ChecksumCCITT ¶
ChecksumCCITT returns the CRC-16 checksum of data using the CCITT polynomial.
func ChecksumCCITTFalse ¶
ChecksumCCITTFalse returns the CRC-16 checksum using what some call the CCITT-False polynomial, which matches what is used by Perl Digest/CRC and Boost for example.
func ChecksumIBM ¶
ChecksumIBM returns the CRC-16 checksum of data using the IBM polynomial.
func ChecksumInverted ¶
ChecksumInverted returns the CRC-16 checksum of data where each byte gets inverted before lookup using the polynomial represented by the Table.
func ChecksumMBus ¶
ChecksumMBus returns the CRC-16 checksum of data using the MBus polynomial. Final result is inverted
func ChecksumSCSI ¶
ChecksumSCSI returns the CRC-16 checksum of data using the SCSI polynomial.
func ChecksumXModem ¶
ChecksumXModem returns the CRC-16 checksum of data using the XMODEM polynomial.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a 256-word table representing the polynomial for efficient processing.
func MakeBitsReversedTable ¶
MakeTable returns the Table constructed from the specified polynomial.