class Digest::CRC8

Implements the CRC8 algorithm.

Constants

INIT_CRC
TABLE

Generated by `./pycrc.py –algorithm=table-driven –model=crc-8 –generate=c`

WIDTH

Public Class Methods

pack(crc) click to toggle source

Packs the CRC8 checksum.

@param [Integer] crc

The checksum to pack.

@return [String]

The packed checksum.
# File lib/digest/crc8.rb, line 42
def self.pack(crc)
  (crc & 0xff).chr
end

Public Instance Methods

update(data) click to toggle source

Updates the CRC8 checksum.

@param [String] data

The data to update the checksum with.
# File lib/digest/crc8.rb, line 52
def update(data)
  data.each_byte do |b|
    @crc = ((@table[(@crc ^ b) & 0xff] ^ (@crc << 8)) & 0xff)
  end

  return self
end