Class: Digest::CRC32

Inherits:
Class
  • Object
show all
Defined in:
lib/gorge/digest/crc32.rb

Instance Method Summary collapse

Constructor Details

#initializeCRC32

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_lengthInteger

Returns the block length of the Digest.

Returns:

  • (Integer)


10
11
12
# File 'lib/gorge/digest/crc32.rb', line 10

def block_length
  1
end

#digest_lengthInteger

Returns the length in bytes of the hash value of the Digest.

Returns:

  • (Integer)


17
18
19
# File 'lib/gorge/digest/crc32.rb', line 17

def digest_length
  4
end

#finishString

Returns the hash value of the Digest packed into a string.

Returns:



43
44
45
# File 'lib/gorge/digest/crc32.rb', line 43

def finish
  [@crc32].pack("N")
end

#resetself

Resets the Digest to its initial state, and returns the Digest modified.

Returns:

  • (self)


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.

Returns:

  • (self)


33
34
35
36
# File 'lib/gorge/digest/crc32.rb', line 33

def update(string)
  @crc32 = Zlib.crc32(string, @crc32)
  self
end