Skip to content

Commit

Permalink
simplify object conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
JotaSe committed May 17, 2019
1 parent 426ab26 commit 22f6430
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/jwt/algos/hmac.rb
Expand Up @@ -7,11 +7,12 @@ module Hmac

def sign(to_sign)
algorithm, msg, key = to_sign.values
authenticator, padded_key = SecurityUtils.rbnacl_fixup(algorithm, key.to_s)
key ||= ''
authenticator, padded_key = SecurityUtils.rbnacl_fixup(algorithm, key)
if authenticator && padded_key
authenticator.auth(padded_key, msg.encode('binary'))
else
OpenSSL::HMAC.digest(OpenSSL::Digest.new(algorithm.sub('HS', 'sha')), key.to_s, msg)
OpenSSL::HMAC.digest(OpenSSL::Digest.new(algorithm.sub('HS', 'sha')), key, msg)
end
end

Expand Down

0 comments on commit 22f6430

Please sign in to comment.