diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/keyring/crypt.rb | 9 | ||||
-rw-r--r-- | lib/keyringer/actions/decrypt.rb | 7 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/keyring/crypt.rb b/lib/keyring/crypt.rb index 8f0ac5d..4c9baaf 100644 --- a/lib/keyring/crypt.rb +++ b/lib/keyring/crypt.rb @@ -20,11 +20,20 @@ module Keyring class Crypt + def initialize + @keyStore = UserConfig.instance.path + '/keys' + end + def decrypt(filename) file = Backend::Fs.new() content = file.get_as_string(filename) crypt = Backend::Crypt.new(nil) return crypt.decrypt(content) end + + def decryptKey(name) + filename = @keyStore + '/' + name + '.asc' + decrypt(filename) + end end end diff --git a/lib/keyringer/actions/decrypt.rb b/lib/keyringer/actions/decrypt.rb index 33f01c2..bac4785 100644 --- a/lib/keyringer/actions/decrypt.rb +++ b/lib/keyringer/actions/decrypt.rb @@ -22,10 +22,9 @@ module Keyringer module Actions class Decrypt def execute - path = Keyring::UserConfig.instance.path - filename = path + '/keys/' + $args[0] + '.asc' - crypt = Keyring::Crypt.new - crypt.decrypt(filename) + raise "Missing key argument" if $args[0].nil? + crypt = Keyring::Crypt.new + crypt.decryptKey($args[0]) end end end |