class FontsDotCom::AuthParam
Attributes
auth[RW]
concatenation[RW]
digest[RW]
hash[RW]
hash64[RW]
hasher[RW]
message[RW]
param[RW]
Public Class Methods
create(message)
click to toggle source
Returns properly-encoded md5 HMAC per www.fonts.com/web-fonts/developers/api/authorizationparameter
# File lib/fonts_dot_com/auth_param.rb, line 10 def self.create(message) self.new(message).compute end
new(message)
click to toggle source
# File lib/fonts_dot_com/auth_param.rb, line 16 def initialize(message) @message = message @digest = OpenSSL::Digest.new('md5') @hasher = OpenSSL::HMAC.new(priv_key, @digest) @concatenation = "#{pub_key}|#{message}" end
Public Instance Methods
compute()
click to toggle source
# File lib/fonts_dot_com/auth_param.rb, line 23 def compute hasher.update(concatenation) @hash = hasher.to_s # Convert hash from hex to base 64 @hash64 = [[@hash].pack("H*")].pack("m0") @auth = "#{pub_key}:#{@hash64}" @param = URI.encode(@auth) return @param end
priv_key()
click to toggle source
# File lib/fonts_dot_com/auth_param.rb, line 39 def priv_key priv_key = FontsDotCom::Config.private_key end
pub_key()
click to toggle source
# File lib/fonts_dot_com/auth_param.rb, line 35 def pub_key pub_key = FontsDotCom::Config.public_key end