class Digest::CRC16DNP

Implements the CRC16 DNP algorithm.

Constants

INIT_CRC
TABLE

Public Instance Methods

finish() click to toggle source
# File lib/digest/crc16_dnp.rb, line 60
def finish
  self.class.pack(~@crc)
end
update(data) click to toggle source

Updates the CRC16 DNP checksum.

@param [String] data

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

  return self
end