1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-10-27 02:33:19 +00:00

add multiple key for encrypt

This commit is contained in:
nishiki 2016-05-07 12:00:19 +02:00
parent 6a1d3a8921
commit 09f53a3c85

View file

@ -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