1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

feat change add key

This commit is contained in:
Adrien Waksberg 2016-12-12 23:09:52 +01:00
parent 0458013def
commit 3575cd9bd7
2 changed files with 9 additions and 10 deletions

View file

@ -334,10 +334,9 @@ class Cli
end
# Add a new public key
# args: key -> the key name to add
# file -> gpg public file to import
def add_key(key, file=nil)
@mpw.add_key(key, file)
# args: key -> the key name or key file to add
def add_key(key)
@mpw.add_key(key)
@mpw.write_data
@mpw.sync(true) if @sync

View file

@ -185,12 +185,12 @@ class MPW
end
# Add a public key
# args: key -> new public key
# file -> public gpg file to import
def add_key(key, file=nil)
if not file.nil? and File.exists?(file)
data = File.open(file).read
GPGME::Key.import(data, armor: true)
# args: key -> new public key file or name
def add_key(key)
if File.exists?(key)
data = File.open(key).read
key_import = GPGME::Key.import(data, armor: true)
key = GPGME::Key.get(key_import.imports[0].fpr).uids[0].email
else
data = GPGME::Key.export(key, armor: true).read
end