Class: Conceal::CLI
- Inherits:
-
Thor
- Object
- Thor
- Conceal::CLI
- Defined in:
- lib/conceal/cli.rb
Instance Method Summary collapse
Instance Method Details
#decrypt(key_file) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/conceal/cli.rb', line 11 def decrypt(key_file) require 'conceal' # load the key raise Thor::Error, 'ERROR: key file is not readable or does not exist' unless File.readable?(key_file) key = IO.read(key_file) # decrypt from stdin encrypted_data = $stdin.read plaintext = Conceal.decrypt(encrypted_data, key: key) $stdout.write(plaintext) $stdout.write("\n") if [:newline] end |
#encrypt(key_file) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/conceal/cli.rb', line 28 def encrypt(key_file) require 'conceal' # load the key raise Thor::Error, 'ERROR: key file is not readable or does not exist' unless File.readable?(key_file) key = IO.read(key_file) # encrypt from stdin plaintext = $stdin.read encrypted_data = Conceal.encrypt(plaintext, key: key) $stdout.write(encrypted_data) $stdout.write("\n") if [:newline] end |
#version ⇒ Object
44 45 46 47 |
# File 'lib/conceal/cli.rb', line 44 def version require 'conceal/version' puts VERSION end |