Class: SHA3::Digest

Inherits:
Digest::Class
  • Object
show all
Defined in:
lib/sha3/doc.rb

Overview

Note:

SHA3::Digest class provides a four sub-classes for the available hash bit lengths (types). You can instantiate a new instance of Digest sub-class for a given type using the following sub-classes:

SHA3::Digest::SHA224([data])
SHA3::Digest::SHA256([data])
SHA3::Digest::SHA384([data])
SHA3::Digest::SHA512([data])

The [data] parameter is optional.

A sub-class of (MRI Ruby based) Digest::Class, it implements SHA3 (Keccak) digest algorithm.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, data) ⇒ Digest

Creates a Digest instance based on given hash bit length (type).

Examples:

digest = SHA3::Digest.new      # => Defaults to 256 bits
digest = SHA3::Digest.new(224) # => Initialize a new 224 bit digest instance
digest = SHA3::Digest::SHA224  # => An alternate method for creating a digest class with 224 bit hash bit length


33
34
35
# File 'lib/sha3/doc.rb', line 33

def initialize(type, data)
  # See function: c_digest_init(...) in ext/sha3/_digest.c
end

Class Method Details

.digest(type, data) ⇒ String

Returns computed hash value for given hash type, and data in bytes.

Examples:

SHA3::Digest.digest(256, 'compute me, please')
SHA3::Digest::SHA256.digest('compute me, please') # => Alternate syntax


115
116
# File 'lib/sha3/doc.rb', line 115

def self.digest(type, data)
end

.hexdigest(type, data) ⇒ String

Returns computed hash value for given hash type, and data in hex (string).

Examples:

SHA3::Digest.hexdigest(256, 'compute me, please')
SHA3::Digest::SHA256.hexdigest('compute me, please') # => Alternate syntax


102
103
# File 'lib/sha3/doc.rb', line 102

def self.hexdigest(type, data)
end

Instance Method Details

#block_lengthNumber

Returns digest block length in bytes.

Examples:

digest = SHA3::Digest::SHA384.new
digest.block_length # Result => 104


81
82
83
# File 'lib/sha3/doc.rb', line 81

def block_length
  # See function: c_digest_block_length(...) in ext/sha3/_digest.c
end

#lengthNumber

Returns message digest length in bytes.

Examples:

digest = SHA3::Digest::SHA256.new
digest.length # Result => 32 (or 256 bits)


70
71
72
# File 'lib/sha3/doc.rb', line 70

def length
  # See function: c_digest_length(...) in ext/sha3/_digest.c
end

#nameString

Returns name of initialized digest



88
89
90
# File 'lib/sha3/doc.rb', line 88

def name
  # See function: c_digest_name(...) in ext/sha3/_digest.c
end

#resetDigest

Resets the Digest object to initial state, abandoning computed data.



59
60
61
# File 'lib/sha3/doc.rb', line 59

def reset
  # See function: c_digest_reset(...) in ext/sha3/_digest.c
end

#update(data) ⇒ Digest Also known as: <<

Updates, and recalculates Message Digest (state) with given data. If a message digest is to be computed from several subsequent sources, then each may be passed individually to the Digest instance.

Examples:

digest = SHA3::Digest::SHA256.new
digest.update('hash me')
digest.update('me too')


49
50
51
# File 'lib/sha3/doc.rb', line 49

def update(data)
  # See function: c_digest_update(...) in ext/sha3/_digest.c
end