lib/megam/api.rb
def encode_header(cmd_parms)
      header_params ={}
      body_digest = OpenSSL::Digest::MD5.digest(cmd_parms[:body])
      body_base64 = Base64.encode64(body_digest)

      current_date = Time.now.strftime("%Y-%m-%d %H:%M")

      data="#{current_date}"+"\n"+"#{cmd_parms[:path]}"+"\n"+"#{body_base64}"

      digest  = OpenSSL::Digest::Digest.new('sha1')
      movingFactor = data.rstrip!
      hash = OpenSSL::HMAC.hexdigest(digest, @api_key, movingFactor)
      final_hmac = @email+':' + hash
      header_params = { :hmac => final_hmac, :date => current_date}
    end
## encode header as per rules.
# The input hash will have
# :api_key, :email, :body, :path
# The output will have
# :hmac
# :date
# (Refer https://github.com/indykish/megamplay.git/test/AuthenticateSpec.scala)
encode header as per rules.
encode header as per rules .
def encode_header(cmd_parms)
      header_params ={}
      body_digest = OpenSSL::Digest::MD5.digest(cmd_parms[:body])
      body_base64 = Base64.encode64(body_digest)
      current_date = Time.now.strftime("%Y-%m-%d %H:%M")
      data="#{current_date}"+"\n"+"#{cmd_parms[:path]}"+"\n"+"#{body_base64}"
      digest  = OpenSSL::Digest::Digest.new('sha1')
      movingFactor = data.rstrip!
      hash = OpenSSL::HMAC.hexdigest(digest, @api_key, movingFactor)
      final_hmac = @email+':' + hash
      header_params = { :hmac => final_hmac, :date => current_date}
    end
def encode_header ( cmd_parms ) header_params = { } body_digest = OpenSSL :: Digest :: MD5 . digest ( cmd_parms [ :body ] ) body_base64 = Base64 . encode64 ( body_digest ) current_date = Time . now . strftime ( "%Y-%m-%d %H:%M" ) data = "#{current_date}" + "\n" + "#{cmd_parms[:path]}" + "\n" + "#{body_base64}" digest = OpenSSL :: Digest :: Digest . new ( 'sha1' ) movingFactor = data . rstrip! hash = OpenSSL :: HMAC . hexdigest ( digest , @api_key , movingFactor ) final_hmac = @email + ':' + hash header_params = { :hmac => final_hmac , :date => current_date } end
encode header as per rules.
encode header as per rules .
cmd_parms