class EncryptedYaml::CLI::CLI

Public Instance Methods

decrypt(filename) click to toggle source
# File lib/encrypted_yaml/cli/cli.rb, line 28
def decrypt(filename)
  raise "File does not exist" unless File.exists? filename
  
  decrypt_options = {
    keyfile: options[:key],
    ivfile: options[:iv]
  }
  
  conf = EncryptedYaml::Configurator.new filename, decrypt_options
  puts conf
end
encrypt(filename) click to toggle source
# File lib/encrypted_yaml/cli/cli.rb, line 10
def encrypt(filename)
  raise "File does not exist" unless File.exists? filename

  enc_options = {
    filename: filename,
    keyfile: options[:key],
    ivfile: options[:iv]
  }
  encrypter = EncryptedYaml::CLI::Encrypt.new enc_options
  encrypted_copy = encrypter.encrypt
  
  new_filename = "#{filename}.enc"
  File.open(new_filename, 'wb') { |f| f.write encrypted_copy }
end