Class: Jerakia::CLI::Secret::Secret

Inherits:
Thor
  • Object
show all
Defined in:
lib/jerakia/cli/secret.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.providerObject (readonly)

Returns the value of attribute provider


13
14
15
# File 'lib/jerakia/cli/secret.rb', line 13

def provider
  @provider
end

Instance Method Details

#decrypt(encrypted) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'lib/jerakia/cli/secret.rb', line 24

def decrypt(encrypted)
  begin
    plaintext = provider.decrypt(encrypted)
  rescue Jerakia::EncryptionError => e
    puts e.message
    exit(1)
  end
  puts plaintext
end

#encrypt(plaintext) ⇒ Object


37
38
39
40
41
42
43
44
45
# File 'lib/jerakia/cli/secret.rb', line 37

def encrypt(plaintext)
  begin
    encrypted = provider.encrypt(plaintext)
  rescue Jerakia::EncryptionError => e
    puts e.message
    exit(1)
  end
  puts encrypted
end