Sha256: 864ddb2e3ffab3a26989bf2ad8dddd96728df565d8b6bf3d47d3f9275fd2a178

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require 'sym/errors'
module Sym
  module Data
    class WrapperStruct < Struct.new(
      # [Blob] Binary encrypted data (possibly compressed)s
      :encrypted_data,
      # [String] IV used to encrypt the datas
      :iv,
      # [String] Name of the cipher used
      :cipher_name,
      # [Integer] For password-encrypted data this is the salt
      :salt,
      # [Integer] Version of the cipher used
      :version,
      # [Boolean] indicates if compression should be applied
      :compress
    )

      define_singleton_method(:new, Class.method(:new))

      VERSION = 1

      attr_accessor :compressed

      def initialize(
        encrypted_data:,
        iv:,
        cipher_name:,
        salt: nil,
        version: VERSION,
        compress: Sym::Configuration.config.compression_enabled
      )
        super(encrypted_data, iv, cipher_name, salt, version, compress)
      end

      def config
        Sym::Configuration.config
      end

      def serialize
        Marshal.dump(self)
      end

      def self.deserialize(data)
        Marshal.load(data)
      end
    end
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sym-3.0.2 lib/sym/data/wrapper_struct.rb
sym-3.0.1 lib/sym/data/wrapper_struct.rb
sym-3.0.0 lib/sym/data/wrapper_struct.rb
sym-2.10.0 lib/sym/data/wrapper_struct.rb