mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
feat change add key
This commit is contained in:
parent
0458013def
commit
3575cd9bd7
2 changed files with 9 additions and 10 deletions
|
@ -334,10 +334,9 @@ class Cli
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new public key
|
# Add a new public key
|
||||||
# args: key -> the key name to add
|
# args: key -> the key name or key file to add
|
||||||
# file -> gpg public file to import
|
def add_key(key)
|
||||||
def add_key(key, file=nil)
|
@mpw.add_key(key)
|
||||||
@mpw.add_key(key, file)
|
|
||||||
@mpw.write_data
|
@mpw.write_data
|
||||||
@mpw.sync(true) if @sync
|
@mpw.sync(true) if @sync
|
||||||
|
|
||||||
|
|
|
@ -185,12 +185,12 @@ class MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a public key
|
# Add a public key
|
||||||
# args: key -> new public key
|
# args: key -> new public key file or name
|
||||||
# file -> public gpg file to import
|
def add_key(key)
|
||||||
def add_key(key, file=nil)
|
if File.exists?(key)
|
||||||
if not file.nil? and File.exists?(file)
|
data = File.open(key).read
|
||||||
data = File.open(file).read
|
key_import = GPGME::Key.import(data, armor: true)
|
||||||
GPGME::Key.import(data, armor: true)
|
key = GPGME::Key.get(key_import.imports[0].fpr).uids[0].email
|
||||||
else
|
else
|
||||||
data = GPGME::Key.export(key, armor: true).read
|
data = GPGME::Key.export(key, armor: true).read
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue