Sha256: 98c9f521b231b21115399ac20d2f7515c8f13bcb4346e583d60176e15bbbe39e

Contents?: true

Size: 521 Bytes

Versions: 11

Compression:

Stored size: 521 Bytes

Contents

require 'digest/crc'

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

    #
    # 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

11 entries across 11 versions & 1 rubygems

Version Path
digest-crc-0.6.5 lib/digest/crc1.rb
digest-crc-0.6.4 lib/digest/crc1.rb
digest-crc-0.6.3 lib/digest/crc1.rb
digest-crc-0.6.2 lib/digest/crc1.rb
digest-crc-0.6.1 lib/digest/crc1.rb
digest-crc-0.6.0 lib/digest/crc1.rb
digest-crc-0.6.0.rc1 lib/digest/crc1.rb
digest-crc-0.5.1 lib/digest/crc1.rb
digest-crc-0.5.0 lib/digest/crc1.rb
digest-crc-0.4.2 lib/digest/crc1.rb
digest-crc-0.4.1 lib/digest/crc1.rb