Sha256: 074776ee874751a8820d2b6221a532f16c2806b1539371edbd18a53c65da9499
Contents?: true
Size: 1.13 KB
Versions: 14
Compression:
Stored size: 1.13 KB
Contents
require 'tempfile' require 'fileutils' module Heirloom module Cipher class File include Heirloom::Cipher::Shared def initialize(args) @config = args[:config] @logger = @config.logger end def encrypt_file(args) @file = args[:file] @secret = args[:secret] @encrypted_file = Tempfile.new('archive.tar.gz.enc') return false unless gpg_in_path? return false unless encrypt replace_file end private def encrypt @logger.info "Encrypting with: '#{command}'" output = `#{command(@secret)}` @logger.debug "Encryption output: '#{output}'" @logger.error "Encryption failed with output: '#{output}'" unless $?.success? $?.success? end def command(secret="XXXXXXXX") "gpg --batch --yes -c --cipher-algo AES256 --passphrase #{secret} --output #{@encrypted_file.path} #{@file} 2>&1" end def replace_file FileUtils.mv @encrypted_file.path, @file @encrypted_file.close! end def logger @logger end end end end
Version data entries
14 entries across 14 versions & 1 rubygems