module JWT::Algos::Hmac

def sign(to_sign)

def sign(to_sign)
  algorithm, msg, key = to_sign.values
  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, msg)
  end
end