class Outback::EncryptionProcessor

Public Instance Methods

cipher() click to toggle source
# File lib/outback/encryption_processor.rb, line 9
def cipher
  @cipher ||= 'aes-256-cbc'
end
to_s() click to toggle source
# File lib/outback/encryption_processor.rb, line 13
def to_s
  "encryption:#{cipher}"
end

Private Instance Methods

process_archive!(archive) click to toggle source
# File lib/outback/encryption_processor.rb, line 19
def process_archive!(archive)
  result = nil
  outfile = Pathname.new("#{archive.filename}.enc")
  logger.debug "Encrypting #{archive} with #{self}"
  Open3.popen3("openssl enc -#{cipher} -pass stdin -in #{archive.filename} -out #{outfile}") do |stdin, stdout, stderr, wait_thr|
    stdin << password
    stdin.close
    result = wait_thr.value
  end
  raise ProcessingError, "error processing archive #{archive} in #{self}" unless result.success?
  raise ProcessingError, "outfile #{outfile} not found" unless outfile.file?
  archive.unlink
  SourceArchive.new(outfile)
end