class Digest::CRC
Base class for all CRC
algorithms.
Constants
Public Class Methods
checksum(data)
click to toggle source
Calculates the CRC
checksum.
@param [String] data
The given data.
@return [Integer]
The CRC checksum.
# File lib/fluent/plugin/digest/crc.rb, line 41 def self.checksum(data) crc = self.new crc << data return crc.checksum end
new()
click to toggle source
Initializes the CRC
checksum.
# File lib/fluent/plugin/digest/crc.rb, line 58 def initialize @crc = self.class.const_get(:INIT_CRC) end
pack(crc)
click to toggle source
Packs the given CRC
checksum.
@return [String]
The packed CRC checksum.
# File lib/fluent/plugin/digest/crc.rb, line 52 def self.pack(crc) '' end
Public Instance Methods
<<(data)
click to toggle source
@see {#update}
# File lib/fluent/plugin/digest/crc.rb, line 89 def <<(data) update(data) return self end
block_length()
click to toggle source
The input block length.
@return [1]
# File lib/fluent/plugin/digest/crc.rb, line 66 def block_length 1 end
checksum()
click to toggle source
The resulting CRC
checksum.
@return [Integer]
The resulting CRC checksum.
# File lib/fluent/plugin/digest/crc.rb, line 108 def checksum @crc ^ self.class.const_get(:XOR_MASK) end
digest_length()
click to toggle source
The length of the digest.
@return [Integer]
The length in bytes.
# File lib/fluent/plugin/digest/crc.rb, line 75 def digest_length (self.class.const_get(:WIDTH) / 8.0).ceil end
finish()
click to toggle source
Finishes the CRC
checksum calculation.
@see {pack}
# File lib/fluent/plugin/digest/crc.rb, line 116 def finish self.class.pack(checksum) end
reset()
click to toggle source
Resets the CRC
checksum.
@return [Integer]
The default value of the CRC checksum.
# File lib/fluent/plugin/digest/crc.rb, line 99 def reset @crc = self.class.const_get(:INIT_CRC) end
update(data)
click to toggle source
Updates the CRC
checksum with the given data.
@param [String] data
The data to update the CRC checksum with.
# File lib/fluent/plugin/digest/crc.rb, line 84 def update(data) end