Sha256: a41929f7625954f909d0f99a72f8c64054d10eb383b1821562834b82b3c9ad6d

Contents?: true

Size: 564 Bytes

Versions: 11

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

require 'openssl'
require 'pg_export/import'

class PgExport
  module Factories
    class CipherFactory
      include Import['config']

      def encryptor
        cipher(:encrypt)
      end

      def decryptor
        cipher(:decrypt)
      end

      private

      ALGORITHM = 'AES-128-CBC'
      private_constant :ALGORITHM

      def cipher(type)
        OpenSSL::Cipher.new(ALGORITHM).tap do |cipher|
          cipher.public_send(type)
          cipher.key = config.dump_encryption_key
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pg_export-1.0.0.rc3 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-1.0.0.rc2 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-1.0.0.rc1 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.7 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.6 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.5 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.4 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.3 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.2 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.1 lib/pg_export/lib/pg_export/factories/cipher_factory.rb
pg_export-0.7.0 lib/pg_export/lib/pg_export/factories/cipher_factory.rb