Class: Hawk::Crypto::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hawk/crypto.rb

Direct Known Subclasses

Bewit, Hash, Mac, TSMac

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/hawk/crypto.rb', line 38

def ==(other)
  if self.class === other
    secure_compare(to_s(:raw => true), other.to_s(:raw => true))
  else
    # assume base64 encoded mac
    secure_compare(to_s(:raw => true), Base64.decode64(other.to_s))
  end
end

#encode64Object



34
35
36
# File 'lib/hawk/crypto.rb', line 34

def encode64
  Base64.encode64(digest).chomp
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/hawk/crypto.rb', line 47

def eql?(other)
  self == other
end

#to_s(options = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/hawk/crypto.rb', line 26

def to_s(options = {})
  if options[:raw]
    digest
  else
    encode64
  end
end