Class Digest::SHA2
In: digest/sha2/lib/sha2.rb
Parent: Digest::Class

A meta digest provider class for SHA256, SHA384 and SHA512.

Methods

Public Class methods

Creates a new SHA2 hash object with a given bit length.

[Source]

# File digest/sha2/lib/sha2.rb, line 23
    def initialize(bitlen = 256)
      case bitlen
      when 256
        @sha2 = Digest::SHA256.new
      when 384
        @sha2 = Digest::SHA384.new
      when 512
        @sha2 = Digest::SHA512.new
      else
        raise ArgumentError, "unsupported bit length: %s" % bitlen.inspect
      end
      @bitlen = bitlen
    end

Public Instance methods

<<(str)

Alias for update

[Source]

# File digest/sha2/lib/sha2.rb, line 55
    def block_length
      @sha2.block_length
    end

[Source]

# File digest/sha2/lib/sha2.rb, line 59
    def digest_length
      @sha2.digest_length
    end

:nodoc:

[Source]

# File digest/sha2/lib/sha2.rb, line 64
    def initialize_copy(other)
      @sha2 = other.instance_eval { @sha2.clone }
    end

:nodoc:

[Source]

# File digest/sha2/lib/sha2.rb, line 69
    def inspect
      "#<%s:%d %s>" % [self.class.name, @bitlen, hexdigest]
    end

:nodoc:

[Source]

# File digest/sha2/lib/sha2.rb, line 38
    def reset
      @sha2.reset
      self
    end

:nodoc:

[Source]

# File digest/sha2/lib/sha2.rb, line 44
    def update(str)
      @sha2.update(str)
      self
    end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.