Sha256: bbab9db346de8c859a5f539ef0dffdb27841bf789746d68401c2f1af6d86f3d6
Contents?: true
Size: 975 Bytes
Versions: 2
Compression:
Stored size: 975 Bytes
Contents
require 'openssl' require 'pg_export/dump' class PgExport module Aes class Base ALGORITHM = 'AES-128-CBC'.freeze def initialize(key:, logger:) @key, @logger = key, logger end def call(source_dump) target_dump = Dump.new(name: target_dump_name, db_name: source_dump.db_name) copy(from: source_dump, to: target_dump) logger.info "Create #{target_dump}" target_dump end private attr_reader :key, :logger def copy(from:, to:) cipher.reset to.open(:write) do |f| from.each_chunk do |chunk| f << cipher.update(chunk) end f << cipher.final end self end def cipher @cipher ||= build_cipher end def build_cipher OpenSSL::Cipher.new(ALGORITHM).tap do |cipher| cipher.public_send(cipher_type) cipher.key = key end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pg_export-0.6.1 | lib/pg_export/aes/base.rb |
pg_export-0.6.0 | lib/pg_export/aes/base.rb |