Class: Keychain

Inherits:
Object
  • Object
show all
Defined in:
lib/keychain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Keychain

Returns a new instance of Keychain.



9
10
11
12
13
# File 'lib/keychain.rb', line 9

def initialize(path)
	@path = path
	load_encryption_keys
	load_contents
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/keychain.rb', line 7

def content
  @content
end

#encryption_keyObject (readonly)

Returns the value of attribute encryption_key.



7
8
9
# File 'lib/keychain.rb', line 7

def encryption_key
  @encryption_key
end

Instance Method Details

#get(name) ⇒ Object



19
20
21
22
23
24
# File 'lib/keychain.rb', line 19

def get(name)
	item = @content.find(name)
	return unless item
	key = Key.new load_file(item.uuid + ".1password")
	key.decrypt(@encryption_key)
end

#unlock(password) ⇒ Object



15
16
17
# File 'lib/keychain.rb', line 15

def unlock(password)
	@unlocked = @encryption_key.unlock(password)
end