Sha256: effe155c476655826d7c0b75c9910942db7408633359f050c69b4210e17fcc6f

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

require 'openssl'

class PgExport
  module Factories
    class CipherFactory
      def initialize(encryption_algorithm:, encryption_key:)
        @encryption_algorithm = encryption_algorithm
        @encryption_key = encryption_key
      end

      def encryptor
        build_cipher(:encrypt)
      end

      def decryptor
        build_cipher(:decrypt)
      end

      private

      attr_reader :encryption_algorithm, :encryption_key

      def build_cipher(type)
        cipher = OpenSSL::Cipher.new(encryption_algorithm)
        cipher.public_send(type)
        cipher.key = encryption_key
        cipher
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_export-1.0.0 lib/pg_export/factories/cipher_factory.rb
pg_export-1.0.0.rc8 lib/pg_export/factories/cipher_factory.rb
pg_export-1.0.0.rc6 lib/pg_export/lib/pg_export/factories/cipher_factory.rb