Skip to content

Commit

Permalink
Use openssl instead of digest
Browse files Browse the repository at this point in the history
  • Loading branch information
dasevilla committed Apr 16, 2014
1 parent 088904f commit a23fd29
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ruby/om.rb
Expand Up @@ -36,8 +36,7 @@

require 'uri'
require 'cgi'
require 'digest'
require 'digest/sha1'
require 'openssl'

if not "".respond_to?(:encoding)
# ruby 1.8 doesn't know about unicode :(
Expand Down Expand Up @@ -136,11 +135,11 @@ def percent_encode(s)
'&' + percent_encode(normalized_params))

# HMAC-SHA1
hmac = Digest::HMAC.new(hmac_key, Digest::SHA1)
hmac.update(signature_base_string)
digest = OpenSSL::Digest::Digest.new('sha1')
hmac = OpenSSL::HMAC.digest(digest, hmac_key, signature_base_string)

# Calculate the digest base 64. Drop the trailing \n
oauth_signature = [hmac.digest].pack('m0').strip
oauth_signature = [hmac].pack('m0').strip

# Build the Authorization header
if realm
Expand Down

0 comments on commit a23fd29

Please sign in to comment.