Sha256: 812985230669fa7580a39822e6a435dbd45049bb3c5d085297793c5c87e2bf7e

Contents?: true

Size: 452 Bytes

Versions: 6

Compression:

Stored size: 452 Bytes

Contents

require 'time'
require 'base64'
require 'openssl'

class Battlenet
  class Authentication
    def initialize(private)
      @private = private
    end

    def sign(verb, path, time)
      string = string_to_sign(verb, path, time)
      signature = OpenSSL::HMAC.digest 'sha1', @private, string
      Base64.encode64 signature
    end

    def string_to_sign(verb, path, time)
      "#{verb.to_s.upcase}\n#{time.httpdate}\n#{path}\n"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
battlenet-1.4.0 lib/battlenet/authentication.rb
battlenet-1.3.0 lib/battlenet/authentication.rb
battlenet-1.2.0 lib/battlenet/authentication.rb
battlenet-1.1.1 lib/battlenet/authentication.rb
battlenet-1.1.0 lib/battlenet/authentication.rb
battlenet-1.0.0 lib/battlenet/authentication.rb