Class: Digest::HMAC

### Home Classes Methods

### In Files

- lib/digest/hmac.rb

### Parent

Digest::Class

### Methods

- ::new
- #<<
- #block_length
- #digest_length
- #initialize_copy
- #inspect
- #reset
- #update

### Files

- LICENSE
- README.rdoc
- TODO

### Class/Module Index

Quicksearch

- OAuth
- OAuth::AccessToken
- OAuth::CLI
- OAuth::Client
- OAuth::Client::Helper
- OAuth::Consumer
- OAuth::ConsumerToken
- OAuth::Error
- OAuth::Helper
- OAuth::OAuthTestHelper
- OAuth::Problem
- OAuth::RequestProxy
- OAuth::RequestProxy::ActionControllerRequest
- OAuth::RequestProxy::Base
- OAuth::RequestProxy::Curl
- OAuth::RequestProxy::Curl::Easy
- OAuth::RequestProxy::EventMachine
- OAuth::RequestProxy::EventMachine::HttpRequest
- OAuth::RequestProxy::JabberRequest
- OAuth::RequestProxy::MockRequest
- OAuth::RequestProxy::Net
- OAuth::RequestProxy::Net::HTTP
- OAuth::RequestProxy::Net::HTTP::HTTPRequest
- OAuth::RequestProxy::RackRequest
- OAuth::RequestProxy::Typhoeus
- OAuth::RequestProxy::Typhoeus::Request
- OAuth::RequestProxy::UnknownRequestType
- OAuth::RequestToken
- OAuth::Server
- OAuth::ServerToken
- OAuth::Signature
- OAuth::Signature::Base
- OAuth::Signature::HMAC
- OAuth::Signature::HMAC::Base
- OAuth::Signature::HMAC::MD5
- OAuth::Signature::HMAC::RMD160
- OAuth::Signature::HMAC::SHA1
- OAuth::Signature::HMAC::SHA2
- OAuth::Signature::MD5
- OAuth::Signature::PLAINTEXT
- OAuth::Signature::RSA
- OAuth::Signature::RSA::SHA1
- OAuth::Signature::SHA1
- OAuth::Signature::UnknownSignatureMethod
- OAuth::Token
- OAuth::Unauthorized
- ActionController
- ActionController::Base
- ActionController::TestRequest
- Digest
- Digest::HMAC
- EventMachine
- EventMachine::HttpClient
- Net
- Net::HTTPGenericRequest
- Object
- String

No matching classes.

# Digest::HMAC

### Public Class Methods

new(key, digester) click to toggle source

    # File lib/digest/hmac.rb, line 44
    def initialize(key, digester)
      @md = digester.new

      block_len = @md.block_length

      if key.bytesize > block_len
        key = @md.digest(key)
      end

      ipad = Array.new(block_len).fill(0x36)
      opad = Array.new(block_len).fill(0x5c)

      key.bytes.each_with_index { |c, i|
        ipad[i] ^= c
        opad[i] ^= c
      }

      @key = key.freeze
      @ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
      @opad = opad.inject('') { |s, c| s << c.chr }.freeze
      @md.update(@ipad)
    end

### Public Instance Methods

<<(text) click to toggle source
Alias for: update
block_length() click to toggle source

    # File lib/digest/hmac.rb, line 95
    def block_length
      @md.block_length
    end

digest_length() click to toggle source

    # File lib/digest/hmac.rb, line 91
    def digest_length
      @md.digest_length
    end

initialize_copy(other) click to toggle source

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

inspect() click to toggle source

    # File lib/digest/hmac.rb, line 99
    def inspect
      sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 });
    end

reset() click to toggle source

    # File lib/digest/hmac.rb, line 77
    def reset
      @md.reset
      @md.update(@ipad)
      self
    end

update(text) click to toggle source

    # File lib/digest/hmac.rb, line 71
    def update(text)
      @md.update(text)
      self
    end

Also aliased as: <<

[Validate]

Generated with the Darkfish Rdoc Generator 2.