Permalink
Browse files

Fixed checksum calculation for CRC16_QT

  • Loading branch information...
1 parent 1596d67 commit 0d1c236596c16a1ea58b67d19aa9118399a22bf4 @joelhelbling joelhelbling committed Feb 12, 2013
Showing with 9 additions and 18 deletions.
  1. +9 −18 lib/digest/crc16_qt.rb
View
@@ -14,23 +14,6 @@ class CRC16QT < CRC16CCITT
REVERSE_DATA = true
- #
- # Packs the CRC16 checksum.
- #
- # @param [Integer] crc
- # The CRC16 checksum to pack.
- #
- # @return [String]
- # The packed CRC16 checksum.
- #
- def self.pack(crc)
- crc ^= FINAL_XOR if FINAL_XOR
- crc = revert_bits crc if REVERSE_CRC_RESULT
-
- return super(crc)
- end
-
- #
# Updates the CRC16 checksum.
#
# @param [String] data
@@ -45,9 +28,16 @@ def update(data)
return self
end
+ def checksum
+ crc = @crc + 0
+ crc ^= FINAL_XOR if FINAL_XOR
+ crc = revert_bits crc if REVERSE_CRC_RESULT
+ return crc
+ end
+
protected
- def self.revert_bits(cc)
+ def revert_bits(cc)
ob = 0
b = (1 << 15)
@@ -70,5 +60,6 @@ def revert_byte(cc)
return ob
end
+
end
end

0 comments on commit 0d1c236

Please sign in to comment.