lib/digest/crc16_qt.rb in digest-crc-0.4.1 vs lib/digest/crc16_qt.rb in digest-crc-0.4.2
- old
+ new
@@ -8,31 +8,33 @@
#
class CRC16QT < CRC16CCITT
FINAL_XOR = 0xffff
- REVERSE_CRC_RESULT = true
-
- REVERSE_DATA = true
-
+ #
# Updates the CRC16 checksum.
#
# @param [String] data
# The data to update the checksum with.
#
def update(data)
data.each_byte do |b|
- b = revert_byte(b) if REVERSE_DATA
+ b = revert_byte(b)
@crc = ((@table[((@crc >> 8) ^ b) & 0xff] ^ (@crc << 8)) & 0xffff)
end
return self
end
+ #
+ # Calculates the CRC checksum value.
+ #
+ # @return [Integer]
+ #
def checksum
- crc = @crc + 0
- crc ^= FINAL_XOR if FINAL_XOR
- crc = revert_bits crc if REVERSE_CRC_RESULT
+ crc = super
+ crc ^= FINAL_XOR
+ crc = revert_bits(crc)
return crc
end
protected