class Trustworthy::CLI::Encrypt
Public Class Methods
_command()
click to toggle source
# File lib/trustworthy/cli/encrypt.rb, line 7 def self._command 'encrypt filename' end
Public Instance Methods
_format_ciphertext(output_file, ciphertext)
click to toggle source
# File lib/trustworthy/cli/encrypt.rb, line 30 def _format_ciphertext(output_file, ciphertext) wrapped_ciphertext = ciphertext.scan(/.{1,64}/).join("\n") output_file.puts('-----BEGIN TRUSTWORTHY ENCRYPTED FILE-----') output_file.puts("Version: Trustworthy/#{Trustworthy::VERSION}") output_file.puts output_file.puts(wrapped_ciphertext) output_file.puts('-----END TRUSTWORTHY ENCRYPTED FILE-----') end
_transform(prompt, options, input_file)
click to toggle source
# File lib/trustworthy/cli/encrypt.rb, line 19 def _transform(prompt, options, input_file) plaintext = input_file.read master_key = prompt.unlock_master_key ciphertext = master_key.encrypt(plaintext) File.open(options[:output_file], 'wb+') do |output_file| _format_ciphertext(output_file, ciphertext) end say("Encrypted #{options[:input_file]} to #{options[:output_file]}") end
parse_options(args)
click to toggle source
Calls superclass method
Trustworthy::CLI::Crypt#parse_options
# File lib/trustworthy/cli/encrypt.rb, line 11 def parse_options(args) options = super(args) unless options.key?(:output_file) options[:output_file] = "#{options[:input_file]}.tw" end options end