Class: Safeguard::Digest::CRC32

Inherits:
Digest::Class
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeCRC32

Returns a new instance of CRC32.



16
17
18
# File 'lib/safeguard/digest/crc32.rb', line 16

def initialize
  reset
end

Instance Attribute Details

#crc32Object (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_lengthObject



39
40
41
# File 'lib/safeguard/digest/crc32.rb', line 39

def block_length
  1
end

#digest_lengthObject



35
36
37
# File 'lib/safeguard/digest/crc32.rb', line 35

def digest_length
  1
end

#finishObject



31
32
33
# File 'lib/safeguard/digest/crc32.rb', line 31

def finish
  [ crc32 ].pack 'N'
end

#resetObject



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