Sha256: 39f1949ecd35761de7d95f54df9d438d19e99240ed24729d52e78a73c3779508

Contents?: true

Size: 469 Bytes

Versions: 2

Compression:

Stored size: 469 Bytes

Contents

class PgExport
  class Aes
    ALGORITHM = 'AES-128-CBC'.freeze

    def initialize(key)
      @key = key
    end

    def build_encryptor
      Aes::Encryptor.new(cipher(:encrypt))
    end

    def build_decryptor
      Aes::Decryptor.new(cipher(:decrypt))
    end

    private

    attr_reader :key

    def cipher(mode)
      OpenSSL::Cipher.new(ALGORITHM).tap do |cipher|
        cipher.public_send(mode.to_sym)
        cipher.key = key
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.5.1 lib/pg_export/services/aes.rb
pg_export-0.5.0 lib/pg_export/services/aes.rb