MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / CRC8

Function CRC8

checksum/crc8.go:27–35  ·  view source on GitHub ↗

CRC8 calculates CRC8 checksum of the given data.

(data []byte, model CRCModel)

Source from the content-addressed store, hash-verified

25
26// CRC8 calculates CRC8 checksum of the given data.
27func CRC8(data []byte, model CRCModel) uint8 {
28 table := getTable(model)
29 crcResult := model.Init
30 crcResult = addBytes(data, model, crcResult, table)
31 if model.RefOut {
32 crcResult = bits.Reverse8(crcResult)
33 }
34 return crcResult ^ model.XorOut
35}
36
37// This function get the result of adding the bytes in data to the crc
38func addBytes(data []byte, model CRCModel, crcResult uint8, table []uint8) uint8 {

Callers 2

TestCalculateCRC8Function · 0.92
BenchmarkCalculateCRC8Function · 0.92

Calls 2

getTableFunction · 0.85
addBytesFunction · 0.85

Tested by 2

TestCalculateCRC8Function · 0.74
BenchmarkCalculateCRC8Function · 0.74