def canonical_representation(params)
      rep = ""

      rep << "#{params[:method].upcase}\n"
      rep << "date:#{params[:date]}\n"
      rep << "nonce:#{params[:nonce]}\n"

      (params[:headers] || {}).sort.each do |pair|
        name,value = *pair
        rep << "#{name.downcase}:#{value}\n"
      end

      rep << params[:path]

      p = (params[:query] || {}).dup

      if !p.empty?
        query = p.sort.map do |key, value|
          "%{key}=%{value}" % {
            :key => Rack::Utils.unescape(key.to_s),
            :value => Rack::Utils.unescape(value.to_s)
          }
        end.join("&")
        rep << "?#{query}"
      end

      rep
    end
def canonical_representation(params)
      rep = ""

      rep << "#{params[:method].upcase}\n"
      rep << "date:#{params[:date]}\n"
      rep << "nonce:#{params[:nonce]}\n"

      (params[:headers] || {}).sort.each do |pair|
        name,value = *pair
        rep << "#{name.downcase}:#{value}\n"
      end

      rep << params[:path]

      p = (params[:query] || {}).dup

      if !p.empty?
        query = p.sort.map do |key, value|
          "%{key}=%{value}" % {
            :key => Rack::Utils.unescape(key.to_s),
            :value => Rack::Utils.unescape(value.to_s)
          }
        end.join("&")
        rep << "?#{query}"
      end

      rep
    end
generates the canonical representation for a given request

 @param [Hash] params the parameters to create the representation with
 @option params [String] :method The HTTP Verb of the request
 @option params [String] :date The date of the request as it was formatted in the request
 @option params [String] :nonce ('') The nonce given in the request
 @option params [String] :path The path portion of the request
 @option params [Hash]   :query ({}) The query parameters given in the request. Must not contain the auth param.
 @option params [Hash]   :headers ({}) All headers given in the request (optional and required)
 @option params [String] :auth_scheme ('HMAC')   The name of the authorization scheme used in the Authorization header and to construct various header-names
 @option params [String] :auth_param ('auth')   The name of the authentication param to use for query based authentication
 @option params [Hash]   :extra_auth_params ({}) Additional parameters to inject in the auth parameter
 @option params [Array<Symbol>]      :ignore_params ([]) Params to ignore for signing
 @option params [String] :auth_header ('Authorization') The name of the authorization header to use
 @option params [String] :auth_header_format ('%{auth_scheme} %{signature}') The format of the authorization header. Will be interpolated with the given options and the signature.
 @option params [String] :nonce_header ('X-#{auth_scheme}-Nonce') The header name for the request nonce
 @option params [String] :alternate_date_header ('X-#{auth_scheme}-Date') The header name for the alternate date header
 @option params [Bool]   :query_based (false) Whether to use query based authentication
 @option params [Bool]   :use_alternate_date_header (false) Use the alternate date header instead of `Date`

 @return [String] the canonical representation