Class: Safeguard::Digest::CRC32
- Inherits:
-
Digest::Class
- Object
- Digest::Class
- Safeguard::Digest::CRC32
- Includes:
- Digest::Instance
- Defined in:
- lib/safeguard/digest/crc32.rb
Overview
Digest implementation of CRC32 using Zlib.
Constant Summary collapse
- INITIAL_VALUE =
0
Instance Attribute Summary collapse
-
#crc32 ⇒ Object
readonly
Returns the value of attribute crc32.
Instance Method Summary collapse
- #block_length ⇒ Object
- #digest_length ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ CRC32
constructor
A new instance of CRC32.
- #reset ⇒ Object
- #update(str) ⇒ Object (also: #<<)
Constructor Details
#initialize ⇒ CRC32
Returns a new instance of CRC32.
16 17 18 |
# File 'lib/safeguard/digest/crc32.rb', line 16 def initialize reset end |
Instance Attribute Details
#crc32 ⇒ Object (readonly)
Returns the value of attribute crc32.
14 15 16 |
# File 'lib/safeguard/digest/crc32.rb', line 14 def crc32 @crc32 end |
Instance Method Details
#block_length ⇒ Object
39 40 41 |
# File 'lib/safeguard/digest/crc32.rb', line 39 def block_length 1 end |
#digest_length ⇒ Object
35 36 37 |
# File 'lib/safeguard/digest/crc32.rb', line 35 def digest_length 1 end |
#finish ⇒ Object
31 32 33 |
# File 'lib/safeguard/digest/crc32.rb', line 31 def finish [ crc32 ].pack 'N' end |
#reset ⇒ Object
20 21 22 |
# File 'lib/safeguard/digest/crc32.rb', line 20 def reset @crc32 = INITIAL_VALUE end |
#update(str) ⇒ Object Also known as: <<
24 25 26 27 |
# File 'lib/safeguard/digest/crc32.rb', line 24 def update(str) @crc32 = Zlib.crc32(str, crc32) self end |