Class: Totpc::Secrets
Overview
handle encrypted secrets store
Instance Method Summary
collapse
Methods included from Passphrase
#ask_noecho, #confirm_passphrase, #passphrase
Constructor Details
#initialize(filename) ⇒ Secrets
Returns a new instance of Secrets.
12
13
14
15
16
17
|
# File 'lib/totpc/secrets.rb', line 12
def initialize(filename)
@filename = filename
@secrets = []
@totp = {}
@window = Window.new
end
|
Instance Method Details
#add(entry) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/totpc/secrets.rb', line 19
def add(entry)
load
return if dup?(entry)
@secrets.reject! { |secret| secret[:id] == entry[:id] }
@secrets.push(entry)
save
end
|
#chpass ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/totpc/secrets.rb', line 52
def chpass
load
new_passphrase = ask_noecho('New Passphrase: ')
new_passphrase2 = ask_noecho('New Passphrase(confirm): ')
abort 'Passphrase does not match' if new_passphrase != new_passphrase2
@passphrase = new_passphrase
save
end
|
#list ⇒ Object
33
34
35
36
37
38
|
# File 'lib/totpc/secrets.rb', line 33
def list
load
@secrets.each do |secret|
puts secret[:id]
end
end
|
#print ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/totpc/secrets.rb', line 40
def print
load
init_totp
@window.init_curses
loop do
@window.show_curses(@secrets, @totp)
break if @window.getch
end
ensure
@window.close
end
|
#remove(id) ⇒ Object
27
28
29
30
31
|
# File 'lib/totpc/secrets.rb', line 27
def remove(id)
load
@secrets.reject! { |secret| secret[:id] == id }
save
end
|