Sha256: f73af9fecfaa7a710864d7de58740a4123f3686d584d34be56a1b977a9f80074

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

module SmileIdentityCore
  class Signature

    def initialize(partner_id, api_key)
      @api_key = api_key
      @partner_id = partner_id.to_i
    end

    def generate_sec_key(timestamp=Time.now.to_i)
      @timestamp = timestamp

      hash_signature = Digest::SHA256.hexdigest([@partner_id, @timestamp].join(":"))
      public_key = OpenSSL::PKey::RSA.new(Base64.strict_decode64(@api_key))
      @sec_key = [Base64.strict_encode64(public_key.public_encrypt(hash_signature)), hash_signature].join('|')

      return {
        sec_key: @sec_key,
        timestamp: @timestamp
      }
  end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smile-identity-core-0.2.0 lib/smile-identity-core/signature.rb
smile-identity-core-0.1.1 lib/smile-identity-core/signature.rb
smile-identity-core-0.1.0 lib/smile-identity-core/signature.rb