Sha256: bd682f7eadd94de4a67617016b9546fc5652d7a143c5ee557bb3e707767f5cbb

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

require 'digest/crc'

module Digest
  #
  # Implements the CRC1 algorithm.
  #
  class CRC1 < CRC

    TABLE = []
    CRC_MASK = 0x00

    #
    # Packs the CRC1 checksum.
    #
    # @return [String]
    #   The CRC1 checksum.
    #
    def self.pack(crc)
      [crc].pack('c*')
    end

    #
    # Updates the CRC1 checksum.
    #
    # @param [String] data
    #   The data to update the checksum with.
    #
    def update(data)
      accum = 0
      data.each_byte { |b| accum += b }

      @crc += (accum % 256)

      return self
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
digest-crc-0.4.0 lib/digest/crc1.rb
digest-crc-0.3.0 lib/digest/crc1.rb
digest-crc-0.2.0 lib/digest/crc1.rb