class Digest::CRC5
Implements the CRC5 algorithm.
Constants
- CRC_MASK
- INIT_CRC
- TABLE
Generated by `./pycrc.py –algorithm=table-driven –model=crc-5 –generate=c`
- WIDTH
- XOR_MASK
Public Class Methods
new()
click to toggle source
Initializes the CRC5 instance.
Calls superclass method
Digest::CRC.new
# File lib/digest/crc5.rb, line 40 def initialize @crc_mask = self.class.const_get(:CRC_MASK) super end
Public Instance Methods
update(data)
click to toggle source
Updates the CRC5 checksum.
@param [String] data
The data to update the checksum with.
# File lib/digest/crc5.rb, line 52 def update(data) data.each_byte do |b| @crc = ((@table[((@crc >> 3) ^ b) & 0xff] ^ (@crc >> 8)) & @crc_mask) end return self end