mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-18 17:10:04 +00:00
add multiple key for encrypt
This commit is contained in:
parent
6a1d3a8921
commit
09f53a3c85
1 changed files with 6 additions and 6 deletions
|
@ -27,8 +27,8 @@ class MPW
|
||||||
# Read mpw file
|
# Read mpw file
|
||||||
def read_data
|
def read_data
|
||||||
@config = nil
|
@config = nil
|
||||||
@keys = []
|
|
||||||
@data = []
|
@data = []
|
||||||
|
@keys = {}
|
||||||
@passwords = {}
|
@passwords = {}
|
||||||
|
|
||||||
data = nil
|
data = nil
|
||||||
|
@ -46,7 +46,7 @@ class MPW
|
||||||
data = decrypt(f.read)
|
data = decrypt(f.read)
|
||||||
|
|
||||||
when /^wallet\/keys\/(?<key>.+)\.pub$/
|
when /^wallet\/keys\/(?<key>.+)\.pub$/
|
||||||
@keys[match['key']] = f.read
|
@keys[Regexp.last_match('key')] = f.read
|
||||||
|
|
||||||
when /^wallet\/passwords\/(?<id>[a-zA-Z0-9]+)\.gpg$/
|
when /^wallet\/passwords\/(?<id>[a-zA-Z0-9]+)\.gpg$/
|
||||||
@passwords[Regexp.last_match('id')] = f.read
|
@passwords[Regexp.last_match('id')] = f.read
|
||||||
|
@ -279,11 +279,11 @@ class MPW
|
||||||
recipients = []
|
recipients = []
|
||||||
crypto = GPGME::Crypto.new(armor: true)
|
crypto = GPGME::Crypto.new(armor: true)
|
||||||
|
|
||||||
# @config['keys'].each do |key|
|
@keys.each_key do |key|
|
||||||
# recipients.push(key)
|
recipients.push(key)
|
||||||
# end
|
end
|
||||||
|
|
||||||
recipients.push(@key)
|
recipients.push(@key) if not recipients.index(@key).nil?
|
||||||
|
|
||||||
return crypto.encrypt(data, recipients: recipients).read
|
return crypto.encrypt(data, recipients: recipients).read
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
|
Loading…
Add table
Reference in a new issue