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 ChecksumMBus(data []byte) uint16
- func ChecksumSCSI(data []byte) uint16
- func Update(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 // 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 is used by Meter-Bus, DNP, ... MBUS = 0x3D65 )
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)
MBusTable is the tabe used for Meter-Bus polynomial.
var SCSITable = makeTable(SCSI)
SCSITable is the table for the SCSI polynomial.
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 ChecksumMBus ¶
ChecksumMBus returns the CRC-16 checksum of data using the MBus polynomial.
func ChecksumSCSI ¶
ChecksumSCSI returns the CRC-16 checksum of data using the SCSI polynomial.
Types ¶
type Hash16 ¶
Hash16 is the common interface implemented by all 16-bit hash functions.
func New ¶
New creates a new Hash16 computing the CRC-16 checksum using the polynomial represented by the Table.
func NewCCITT ¶
func NewCCITT() Hash16
NewCCITT creates a new hash.Hash16 computing the CRC-16 checksum using the CCITT polynomial.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a 256-word table representing the polynomial for efficient processing.
func MakeBitsReversedTable ¶
MakeBitsReversedTable returns the Table constructed from the specified polynomial.
func MakeTableNoXOR ¶
MakeTableNoXOR returns the Table constructed from the specified polynomial. Updates happen without XOR in and XOR out.