Sha256: 94d7edb18d77fb233756cd1a5d38691ce4c78b0490916672a88330f68f0c15a5

Contents?: true

Size: 481 Bytes

Versions: 2

Compression:

Stored size: 481 Bytes

Contents

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

    def self.encryptor(key)
      initialize_aes(:encrypt, key)
    end

    def self.decryptor(key)
      initialize_aes(:decrypt, key)
    end

    def self.initialize_aes(mode, key)
      raise ArgumentError, 'Only :encrypt or :decrypt are allowed' unless %i(encrypt decrypt).include?(mode)
      aes = OpenSSL::Cipher::Cipher.new(ALG)
      aes.public_send(mode.to_sym)
      aes.key = key
      aes
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.4.1 lib/pg_export/services/aes.rb
pg_export-0.4.0 lib/pg_export/services/aes.rb