lib/rapid-vaults/decrypt.rb in rapid-vaults-1.1.0 vs lib/rapid-vaults/decrypt.rb in rapid-vaults-1.1.1

- old
+ new

@@ -15,30 +15,33 @@ decipher.auth_data = settings.key?(:pw) ? settings[:pw] : '' # output the decryption if settings[:ui] == :cli # output to file - File.write('decrypted.txt', decipher.update(settings[:file]) + decipher.final) - puts 'Your decrypted.txt has been written out to the current directory.' + File.write("#{settings[:outdir]}decrypted.txt", decipher.update(settings[:file]) + decipher.final) + puts "Your decrypted.txt has been written out to #{settings[:outdir]}." elsif settings[:ui] == :api # output to string decipher.update(settings[:file]) + decipher.final end end # decrypts a string with gpgme def self.gpgme(settings) require 'gpgme' + # check if GPGHOME env was set + puts "Environment variable 'GNUPGHOME' was not set. Files in #{ENV['HOME']}/.gnupg will be used for authentication." unless ENV['GNUPGHOME'] + # setup the decryption parameters encrypted = GPGME::Data.new(settings[:file]) crypto = GPGME::Crypto.new(armor: true, pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK) # output the decryption if settings[:ui] == :cli # output to file - File.write('decrypted.txt', crypto.decrypt(encrypted, password: settings[:pw]).read) - puts 'Your decrypted.txt has been written out to the current directory.' + File.write("#{settings[:outdir]}decrypted.txt", crypto.decrypt(encrypted, password: settings[:pw]).read) + puts "Your decrypted.txt has been written out to #{settings[:outdir]}." elsif settings[:ui] == :api # output to string crypto.decrypt(encrypted, password: settings[:pw]).read end end