Class: Digest::CRC1
Overview
Implements the CRC1 algorithm.
Constant Summary
Constants inherited from CRC
Digest::CRC::INIT_CRC, Digest::CRC::TABLE, Digest::CRC::WIDTH, Digest::CRC::XOR_MASK
Class Method Summary collapse
-
.pack(crc) ⇒ String
Packs the CRC1 checksum.
Instance Method Summary collapse
-
#update(data) ⇒ Object
Updates the CRC1 checksum.
Methods inherited from CRC
#<<, #block_length, checksum, #checksum, #digest_length, #finish, #initialize, #reset
Constructor Details
This class inherits a constructor from Digest::CRC
Class Method Details
.pack(crc) ⇒ String
Packs the CRC1 checksum.
15 16 17 |
# File 'lib/digest/crc1.rb', line 15 def self.pack(crc) [crc].pack('c*') end |
Instance Method Details
#update(data) ⇒ Object
Updates the CRC1 checksum.
25 26 27 28 29 30 31 32 |
# File 'lib/digest/crc1.rb', line 25 def update(data) accum = 0 data.each_byte { |b| accum += b } @crc += (accum % 256) return self end |