Class: RijnCLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/rijn_cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rijn_cli.rb', line 10

def self.exit_on_failure?
  true
end

Instance Method Details

#decryptObject



22
23
24
25
26
27
28
29
30
# File 'lib/rijn_cli.rb', line 22

def decrypt
  value = options[:value] || prompt_ask("What's the value?")
  key = options[:key] || prompt_mask("What's the key?")

  write_info(Rijn.decrypt(value, key))
rescue Rijn::InvalidKeyError, Rijn::AuthenticationError => e
  write_error(e.message)
  exit 1
end

#encryptObject



35
36
37
38
39
40
41
42
43
# File 'lib/rijn_cli.rb', line 35

def encrypt
  value = options[:value] || prompt_ask("What's the value?")
  key = options[:key] || prompt_mask("What's the key?")

  write_info(Rijn.encrypt(value, key))
rescue Rijn::InvalidKeyError, Rijn::AuthenticationError => e
  write_error(e.message)
  exit 1
end

#keygenObject



47
48
49
50
51
52
# File 'lib/rijn_cli.rb', line 47

def keygen
  write_info(Rijn.generate_key(options[:bits]))
rescue Rijn::InvalidKeyError => e
  write_error(e.message)
  exit 1
end

#versionObject



15
16
17
# File 'lib/rijn_cli.rb', line 15

def version
  write_info(Rijn::VERSION)
end