Class: Digest::CRC32
- Inherits:
-
Class
- Object
- Class
- Digest::CRC32
- Defined in:
- lib/gorge/digest/crc32.rb
Instance Method Summary collapse
-
#block_length ⇒ Integer
Returns the block length of the Digest.
-
#digest_length ⇒ Integer
Returns the length in bytes of the hash value of the Digest.
-
#finish ⇒ String
Returns the hash value of the Digest packed into a string.
-
#initialize ⇒ CRC32
constructor
A new instance of CRC32.
-
#reset ⇒ self
Resets the Digest to its initial state, and returns the Digest modified.
-
#update(string) ⇒ self
(also: #<<)
Updates the Digest using the given string, and returns the Digest modified.
Constructor Details
#initialize ⇒ CRC32
Returns a new instance of CRC32.
3 4 5 |
# File 'lib/gorge/digest/crc32.rb', line 3 def initialize reset end |
Instance Method Details
#block_length ⇒ Integer
Returns the block length of the Digest.
10 11 12 |
# File 'lib/gorge/digest/crc32.rb', line 10 def block_length 1 end |
#digest_length ⇒ Integer
Returns the length in bytes of the hash value of the Digest.
17 18 19 |
# File 'lib/gorge/digest/crc32.rb', line 17 def digest_length 4 end |
#finish ⇒ String
Returns the hash value of the Digest packed into a string.
43 44 45 |
# File 'lib/gorge/digest/crc32.rb', line 43 def finish [@crc32].pack("N") end |
#reset ⇒ self
Resets the Digest to its initial state, and returns the Digest modified.
25 26 27 |
# File 'lib/gorge/digest/crc32.rb', line 25 def reset @crc32 = 0 end |
#update(string) ⇒ self Also known as: <<
Updates the Digest using the given string, and returns the Digest modified.
33 34 35 36 |
# File 'lib/gorge/digest/crc32.rb', line 33 def update(string) @crc32 = Zlib.crc32(string, @crc32) self end |