Sha256: b4d2a706ea82457805bff7d4141d1a871eba39715b8ec8ba90170f4685428550
Contents?: true
Size: 888 Bytes
Versions: 2
Compression:
Stored size: 888 Bytes
Contents
require "openssl" require "base64" require "azure/configuration" module Azure module Core # Public: Utility class to sign strings with HMAC-256 and then encode the # signed string using Base64. class Signer # The Azure account's access key. attr :access_key # Public: Initialize the Signer. # # access_key - The Azure access_key encoded in Base64. Defaults to the one # in the global configuration. def initialize(access_key=Azure.config.access_key) @access_key = Base64.strict_decode64(access_key) end # Public: Generate an HMAC signature. # # body - The string to sign. # # Returns a Base64 String signed with HMAC. def sign(body) signed = OpenSSL::HMAC.digest("sha256", access_key, body) Base64.strict_encode64(signed) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
azure-0.1.1 | lib/azure/core/signer.rb |
azure-0.1.0 | lib/azure/core/signer.rb |