class Digest::CRC32
Implements the CRC32 algorithm.
Constants
- INIT_CRC
- TABLE
Generated by `./pycrc.py –algorithm=table-driven –model=crc-32 –generate=c`
- WIDTH
- XOR_MASK
Public Class Methods
pack(crc)
click to toggle source
Packs the CRC32 checksum.
@param [Integer] crc
The checksum to pack.
@return [String]
The packed checksum.
# File lib/digest/crc32.rb, line 92 def self.pack(crc) buffer = '' buffer << ((crc & 0xff000000) >> 24).chr buffer << ((crc & 0xff0000) >> 16).chr buffer << ((crc & 0xff00) >> 8).chr buffer << (crc & 0xff).chr buffer end
Public Instance Methods
update(data)
click to toggle source
Updates the CRC32 checksum.
@param [String] data
The data to update the checksum with.
# File lib/digest/crc32.rb, line 109 def update(data) data.each_byte do |b| @crc = (((@crc >> 8) & 0x00ffffff) ^ @table[(@crc ^ b) & 0xff]) end return self end