Sha256: cc01fa9dd3ced6760f1b5423add62fa2553a01fc978a2284a632484d282d224a

Contents?: true

Size: 487 Bytes

Versions: 30

Compression:

Stored size: 487 Bytes

Contents

require 'openssl'

module RestCore; end
module RestCore::Hmac
  module_function
  # Fallback to ruby-hmac gem in case system openssl
  # lib doesn't support SHA256 (OSX 10.5)
  def sha256 key, data
    OpenSSL::HMAC.digest('sha256', key, data)
  rescue RuntimeError
    require 'hmac-sha2'
    HMAC::SHA256.digest(key, data)
  end

  def sha1 key, data
    OpenSSL::HMAC.digest('sha1', key, data)
  rescue RuntimeError
    require 'hmac-sha1'
    HMAC::SHA1.digest(key, data)
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rest-core-2.1.2 lib/rest-core/util/hmac.rb
rest-core-2.1.1 lib/rest-core/util/hmac.rb
rest-core-2.1.0 lib/rest-core/util/hmac.rb
rest-core-2.0.4 lib/rest-core/util/hmac.rb
rest-core-2.0.3 lib/rest-core/util/hmac.rb
rest-core-2.0.2 lib/rest-core/util/hmac.rb
rest-core-2.0.1 lib/rest-core/util/hmac.rb
rest-core-2.0.0 lib/rest-core/util/hmac.rb
rest-core-1.0.3 lib/rest-core/util/hmac.rb
rest-core-1.0.2 lib/rest-core/util/hmac.rb
rest-core-1.0.1 lib/rest-core/util/hmac.rb
rest-core-1.0.0 lib/rest-core/util/hmac.rb
rest-core-0.8.2 lib/rest-core/util/hmac.rb
rest-core-0.8.1 lib/rest-core/util/hmac.rb
rest-core-0.8.0 lib/rest-core/util/hmac.rb
rest-core-0.7.2 lib/rest-core/util/hmac.rb
rest-core-0.7.0 lib/rest-core/util/hmac.rb
rest-core-0.4.0 lib/rest-core/util/hmac.rb
rest-core-0.4.0.pre.2 lib/rest-core/util/hmac.rb
rest-core-0.4.0.pre.1 lib/rest-core/util/hmac.rb