Sha256: a5f6494ac5db3985e278b6c218a50cb474d984e1eea8ddab4ed81b0910cab132

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

require 'base64'
require 'zlib'

require 'sym/crypt/configuration'

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

      def initialize(data, compress)
        self.data         = data
        self.data_encoded = Marshal.dump(data)
        self.data_encoded = Zlib::Deflate.deflate(data_encoded, compression_level) if compress
        self.data_encoded = Base64.urlsafe_encode64(data_encoded)
      end

      def compression_level
        Sym::Crypt::Configuration.config.compression_level
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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