class Digest::CRC1

Implements the CRC1 algorithm.

Public Class Methods

pack(crc) click to toggle source

Packs the CRC1 checksum.

@return [String]

The CRC1 checksum.
# File lib/digest/crc1.rb, line 15
def self.pack(crc)
  [crc].pack('c*')
end

Public Instance Methods

update(data) click to toggle source

Updates the CRC1 checksum.

@param [String] data

The data to update the checksum with.
# File lib/digest/crc1.rb, line 25
def update(data)
  accum = 0
  data.each_byte { |b| accum += b }

  @crc += (accum % 256)

  return self
end