Sha256: d46810fe52b22d94167e399ebf85e4d4ece441a44b03d3c4886a87de54dd9732

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

require 'sym/crypt/errors'
require 'base64'
require 'zlib'

module Sym
  module Data
    class Decoder
      attr_accessor :data, :data_encoded, :data

      def initialize(data_encoded, compress)
        self.data_encoded = data_encoded
        self.data         = begin
          Base64.urlsafe_decode64(data_encoded)
        rescue
          data_encoded
        end

        if compress.nil? || compress # auto-guess
          self.data = begin
            Zlib::Inflate.inflate(data)
          rescue Zlib::Error => e
            data
          end
        end
        self.data = Marshal.load(data)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sym-crypt-1.2.0 lib/sym/data/decoder.rb