pwss 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +28 -34
- data/bin/pwss +109 -56
- data/lib/pwss.rb +4 -3
- data/lib/pwss/cipher.rb +20 -9
- data/lib/pwss/entry.rb +9 -3
- data/lib/pwss/fileops.rb +1 -1
- data/lib/pwss/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2553a7a2e55ca432b8237846c9ca874415ed7f11
|
4
|
+
data.tar.gz: 49bb878f3ef6444b3138c498246280d1ad090e12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44735ee5e8235b212e37d75b9e167743bcf375af8dcb2bd822b895aef1b266b37e2e565c090278e83f5f0ebd6d920aa95c74e71314d7dd85a2da7cd8cd49db28
|
7
|
+
data.tar.gz: 1b20540be432cec70e2dae8bc940976570516a453790a8453d8f8f5dcb13dbf53c071cc867ade7e94be9f8412c9d9054a9ea0964d894800cd0c692681dab8499
|
data/README.textile
CHANGED
@@ -2,34 +2,19 @@ h1. Pwss
|
|
2
2
|
|
3
3
|
A password manager in the spirit of "pws":https://github.com/janlelis/pws.
|
4
4
|
|
5
|
-
PWSS can store multiple entries in a file and it allows user to specify various types of entries (e.g., BankAccount) and different infos for each entry (e.g., URL for Internet passwords).
|
6
|
-
|
7
5
|
Features:
|
8
6
|
|
9
|
-
* PWSS manages password files
|
10
|
-
|
11
|
-
|
12
|
-
* Entries in a password file can be of
|
13
|
-
|
14
|
-
|
15
|
-
*
|
16
|
-
|
17
|
-
- Entry: title, username, password, url, description
|
18
|
-
- CreditCard: title, issuer, name_on_card, card_number, valid_from,
|
19
|
-
valid_till, verification_number, pin, url, notes
|
20
|
-
- BankAccount: title, name, iban, url, description
|
21
|
-
- SoftwareLicense: title, version, license_number, licensed_to,
|
22
|
-
email, purchased_on
|
23
|
-
|
24
|
-
* CRUD (create, read, update, delete) commands are available to
|
25
|
-
operate on entries and password files
|
26
|
-
|
27
|
-
* The user can manage different password files (e.g., work, personal)
|
7
|
+
* PWSS manages password *files*:
|
8
|
+
** A password file can store different entries (password and other sensitive information)
|
9
|
+
** The user can manage different password files (e.g., work, personal)
|
10
|
+
* Entries in a password file can be any of Entry, CreditCard, BankAccount, SoftwareLicense. Each type stores a different set of infos:
|
11
|
+
** *Entry:* title, username, password, url, description
|
12
|
+
** *CreditCard:* title, issuer, name_on_card, card_number, valid_from, valid_till, verification_number, pin, url, notes
|
13
|
+
** *BankAccount:* title, name, iban, url, description
|
14
|
+
** *SoftwareLicense: title, version, license_number, licensed_to, email, purchased_on
|
28
15
|
* Password files can be encrypted
|
29
|
-
* Encrypted password files can be decrypted, for instance, to batch process
|
30
|
-
|
31
|
-
* Entries are human-readable (and editable), when the password file is not
|
32
|
-
encrypted
|
16
|
+
* Encrypted password files can be decrypted, for instance, to batch process entries, to migrate to another tool, or to manually edit entries
|
17
|
+
* Entries are human-readable (and editable), when the password file is not encrypted
|
33
18
|
|
34
19
|
h2. Installation
|
35
20
|
|
@@ -42,12 +27,12 @@ h2. Quick Start
|
|
42
27
|
Try the following:
|
43
28
|
|
44
29
|
bc. $ pwss init
|
45
|
-
$ pwss add
|
46
|
-
$ pwss get
|
30
|
+
$ pwss add First Entry
|
31
|
+
$ pwss get First
|
47
32
|
|
48
33
|
For some more information:
|
49
34
|
|
50
|
-
bc. $ pwss
|
35
|
+
bc. $ pwss man # get information from the command line
|
51
36
|
$ pwss -h # command syntax
|
52
37
|
|
53
38
|
h2. Detailed Instructions
|
@@ -56,9 +41,9 @@ h2. Detailed Instructions
|
|
56
41
|
|
57
42
|
A typical usage scenario is the following:
|
58
43
|
|
59
|
-
# @pwss init@ will create a new encrypted password safe in @~/.pwss.yaml.enc@
|
44
|
+
# @pwss init@ will create a new encrypted password safe in @~/.pwss.yaml.enc@. If you specify a filename without the @.enc@ extension, the password safe will be stored in plain text (see below).
|
60
45
|
# @pwss add@ will add a new entry to the file
|
61
|
-
# @pwss get string@ will retrieve all entries whose *title* contains @string
|
46
|
+
# @pwss get string@ will retrieve all entries whose *title* contains @string@, let the user choose an entry, and make the password of the chosen entry available in the clipboard for a given period (the default is 30 seconds; the option @-w@ controls the amount of time the password is available)
|
62
47
|
|
63
48
|
*Using multiple safes.* If you want to create multiple password files or store a password file in a non-standard location, use the @-f@ (@--filename@) option:
|
64
49
|
|
@@ -68,17 +53,17 @@ A typical usage scenario is the following:
|
|
68
53
|
|
69
54
|
*Do not forget to use the extension @.enc@, if your password file to be encrypted.* (See "Encrypted and Plain files", below.)
|
70
55
|
|
71
|
-
*Controlling how long passwords are made available* Use the @-w@ option to determine how long the password is made available in the clipboard. For instance:
|
56
|
+
*Controlling how long passwords are made available for* Use the @-w@ option to determine how long the password is made available in the clipboard. For instance:
|
72
57
|
|
73
58
|
bc. $ pwss get my_email -w 3
|
74
59
|
|
75
|
-
will retrieve entry whose title is @my_email@ and make the password available in the clipboard for @3@ seconds.
|
60
|
+
will retrieve a user selected entry whose title is @my_email@ and make the password available in the clipboard for @3@ seconds.
|
76
61
|
|
77
62
|
Use @0@ to keep the password in the clipboard till a key is pressed.
|
78
63
|
|
79
64
|
*Automatically Generated Password* pwss can automatically generate passwords for entries which are added or updated.
|
80
65
|
|
81
|
-
The generated passwords are random sequences of chars and symbols
|
66
|
+
The generated passwords are random sequences of chars and symbols. No attempt is made to make them readable or simpler to remember. You can use the @-a@ option to limit the generator to use only digits and letters ([0-9a-zA-Z]): this is useful, for instance, for websites which do accept certain classes of characters.
|
82
67
|
|
83
68
|
Use the @-g LENGTH@ option to determine the password length.
|
84
69
|
|
@@ -102,7 +87,7 @@ By contrast,
|
|
102
87
|
|
103
88
|
bc. $ pwss init -f a.yaml
|
104
89
|
|
105
|
-
Encrypting sensitive information is a good idea. (Just in case you were
|
90
|
+
Encrypting sensitive information is a good idea. (Just in case you were expecting a witty statement.) However, if you use @pwss@ to store non-critical infomation, prefer to edit the password safe with a text editor, or use another application for managing encryption and decryption, using @pwss@ with the file in plain format might be more convenient.
|
106
91
|
|
107
92
|
*Moving from plain to encrypted.* You can use the @encrypt@ and @decrypt@ commands at any time to move from the plain to the encrypted format.
|
108
93
|
|
@@ -163,6 +148,15 @@ Notice that only @title@ and @password@ are required.
|
|
163
148
|
|
164
149
|
h2. Changelog
|
165
150
|
|
151
|
+
* *Release 0.5.0* This is mainly a release focused on improving interaction. Small changes to the command syntax and improved exit conditions. In details:
|
152
|
+
** *add* now accepts the title in the command line. For instance @pwss add New Entry@
|
153
|
+
** *new* is now an alias for the *add* command
|
154
|
+
** *update* now requires to specify the field: use @-p@, @--password@, or @--field password@, if you want to update the password
|
155
|
+
** show the usage summary, if no arguments are given
|
156
|
+
** *C-c* is now trapped and properly managed (clearing the clipboard)
|
157
|
+
** decryption errors are now properly managed
|
158
|
+
** the content of the clipboard is now restored after the waiting period
|
159
|
+
|
166
160
|
* *Release 0.4.0*
|
167
161
|
** New @--stdout@ option will output password to standard output (useful for integration with other applications)
|
168
162
|
** New @--select N@ option will automatically select the @N@th entry (rather than asking the user to select an entry).
|
data/bin/pwss
CHANGED
@@ -24,6 +24,47 @@ def file2string filename
|
|
24
24
|
[string, password]
|
25
25
|
end
|
26
26
|
|
27
|
+
# this is to support command aliases: add and new
|
28
|
+
# maybe not the the best of places where to define a function
|
29
|
+
def add opts, args
|
30
|
+
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
31
|
+
waiting = opts.to_hash[:wait] || DEFAULT_SECS
|
32
|
+
length = opts.to_hash[:generate] || 0
|
33
|
+
type = opts.to_hash[:type] || "Entry"
|
34
|
+
alnum = opts.to_hash[:alnum]
|
35
|
+
|
36
|
+
default_title = args.join(" ")
|
37
|
+
string, password = file2string filename
|
38
|
+
|
39
|
+
puts "Adding #{default_title != "" ? "entry '" + default_title + "'" : "an entry"} of type '#{type}' to #{filename}"
|
40
|
+
# ask for a new entry
|
41
|
+
if default_title != "" then
|
42
|
+
overrides = {"title" => ["Readline.readline('title (leave empty for \"#{default_title}\"): ')", "'#{default_title}'"]}
|
43
|
+
end
|
44
|
+
pe = eval("Pwss::" + type).new
|
45
|
+
pe.ask length, alnum, overrides
|
46
|
+
|
47
|
+
# add the entry to the safe
|
48
|
+
entries = YAML::load(string) || Array.new
|
49
|
+
entries << pe.entry
|
50
|
+
|
51
|
+
# check status of input file and encrypt if necessary
|
52
|
+
if FileOps::encrypted? filename then
|
53
|
+
new_string = Cipher::encrypt entries.to_yaml, password
|
54
|
+
else
|
55
|
+
new_string = entries.to_yaml
|
56
|
+
end
|
57
|
+
|
58
|
+
FileOps::backup filename
|
59
|
+
FileOps::save filename, new_string
|
60
|
+
|
61
|
+
puts "Entry added."
|
62
|
+
|
63
|
+
# make password available in the clipboard, if there is a password to make available
|
64
|
+
if pe.entry["password"]
|
65
|
+
Cipher.password_to_clipboard pe.entry["password"], waiting
|
66
|
+
end
|
67
|
+
end
|
27
68
|
|
28
69
|
version = Pwss::VERSION
|
29
70
|
man = <<EOS
|
@@ -39,13 +80,13 @@ DESCRIPTION
|
|
39
80
|
|
40
81
|
Features:
|
41
82
|
|
42
|
-
* PWSS manages password files
|
43
|
-
|
83
|
+
* PWSS manages password *files*:
|
84
|
+
- A password file can store different entries (password and other
|
85
|
+
sensitive information)
|
86
|
+
- The user can manage different password files (e.g., work, personal)
|
44
87
|
|
45
|
-
* Entries in a password file can be of
|
46
|
-
|
47
|
-
|
48
|
-
* Information stored for each type:
|
88
|
+
* Entries in a password file can be any of Entry, CreditCard, BankAccount,
|
89
|
+
SoftwareLicense. Each type stores a different set of infos:
|
49
90
|
|
50
91
|
- Entry: title, username, password, url, description
|
51
92
|
- CreditCard: title, issuer, name_on_card, card_number, valid_from,
|
@@ -54,13 +95,11 @@ DESCRIPTION
|
|
54
95
|
- SoftwareLicense: title, version, license_number, licensed_to,
|
55
96
|
email, purchased_on
|
56
97
|
|
57
|
-
* CRUD (create, read, update, delete) commands are available to
|
58
|
-
operate on entries and password files
|
59
|
-
|
60
|
-
* The user can manage different password files (e.g., work, personal)
|
61
98
|
* Password files can be encrypted
|
99
|
+
|
62
100
|
* Encrypted password files can be decrypted, for instance, to batch process
|
63
101
|
entries, to migrate to another tool, or to manually edit entries
|
102
|
+
|
64
103
|
* Entries are human-readable (and editable), when the password file is not
|
65
104
|
encrypted
|
66
105
|
|
@@ -69,7 +108,7 @@ EXAMPLES
|
|
69
108
|
|
70
109
|
# scenario
|
71
110
|
pwss init -f a.enc # generate an encrypted safe a.enc
|
72
|
-
pwss add -f a.enc -g 16 -a # add an entry (
|
111
|
+
pwss add -f a.enc -g 16 -a # add an entry (pwss will generate a random 16-char password)
|
73
112
|
pwss get -f a.enc my secret account # find an entry
|
74
113
|
|
75
114
|
VERSION
|
@@ -80,6 +119,7 @@ LICENSE
|
|
80
119
|
|
81
120
|
SEE ALSO
|
82
121
|
pwss -h
|
122
|
+
pwss man
|
83
123
|
https://github.com/avillafiorita/pwss
|
84
124
|
EOS
|
85
125
|
|
@@ -88,7 +128,8 @@ EOS
|
|
88
128
|
#
|
89
129
|
# Main App Starts Here!
|
90
130
|
#
|
91
|
-
|
131
|
+
cmd = nil
|
132
|
+
opts = Slop.parse :help => true, :strict => true do
|
92
133
|
# the default filename
|
93
134
|
DEFAULT_FILENAME = File.join(Dir.home, ".pwss.yaml.enc")
|
94
135
|
# the default number of seconds password is available in the clipboard
|
@@ -98,15 +139,17 @@ opts = Slop.parse :help => true do
|
|
98
139
|
|
99
140
|
##############################################################################
|
100
141
|
on "-v", "--version", 'Print version information' do
|
142
|
+
cmd = "version"
|
101
143
|
puts "pwss version #{version}"
|
102
144
|
end
|
103
145
|
|
104
146
|
##############################################################################
|
105
|
-
command :
|
106
|
-
banner "pwss
|
147
|
+
command :man do
|
148
|
+
banner "pwss man"
|
107
149
|
description "Print detailed information about how to use pwss"
|
108
150
|
|
109
151
|
run do |_, _|
|
152
|
+
cmd = "man"
|
110
153
|
puts man
|
111
154
|
end
|
112
155
|
end
|
@@ -119,6 +162,7 @@ opts = Slop.parse :help => true do
|
|
119
162
|
on "-f", "--filename=", "Password file to create. Use extension '.enc' to encrypt it."
|
120
163
|
|
121
164
|
run do |opts, args|
|
165
|
+
cmd = "init"
|
122
166
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
123
167
|
|
124
168
|
if File.exists?(filename)
|
@@ -151,6 +195,8 @@ opts = Slop.parse :help => true do
|
|
151
195
|
on "-f", "--filename=", "Password file to use."
|
152
196
|
|
153
197
|
run do |opts, args|
|
198
|
+
cmd = "list"
|
199
|
+
|
154
200
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
155
201
|
|
156
202
|
string, _ = file2string filename
|
@@ -171,6 +217,8 @@ opts = Slop.parse :help => true do
|
|
171
217
|
on "--select=", "Select the N-th matching entry", as: Integer
|
172
218
|
|
173
219
|
run do |opts, args|
|
220
|
+
cmd = "get"
|
221
|
+
|
174
222
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
175
223
|
waiting = opts.to_hash[:wait] || DEFAULT_SECS
|
176
224
|
stdout_opt = opts.to_hash[:stdout]
|
@@ -191,51 +239,38 @@ opts = Slop.parse :help => true do
|
|
191
239
|
|
192
240
|
##############################################################################
|
193
241
|
command :add do
|
194
|
-
banner "pwss add [options]"
|
242
|
+
banner "pwss add [options] [entry title]"
|
195
243
|
description "Add an entry and copy its password in the clipboard"
|
196
244
|
|
197
|
-
on "-f", "--filename=", "Password file to use
|
245
|
+
on "-f", "--filename=", "Password file to use"
|
198
246
|
on "-w", "--wait=", "Seconds password is available in the clipboard (0 = interactive)", as: Integer
|
199
|
-
|
247
|
+
|
200
248
|
on "-e", "--entry=", "Create an entry of type TYPE (Entry, CreditCard, BankAccount, SoftwareLicense).\n Default to 'Entry', which is good enough for websites credentials"
|
201
249
|
|
202
250
|
on "-g", "--generate=", "Generate a random password of given length.", as: Integer
|
203
251
|
on "-a", "--alnum", "Use only alphanumeric chars for the randomly generated password"
|
204
252
|
|
205
253
|
run do |opts, args|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
alnum = opts.to_hash[:alnum]
|
211
|
-
|
212
|
-
string, password = file2string filename
|
213
|
-
|
214
|
-
puts "Adding an entry of type: #{type}"
|
215
|
-
# ask for a new entry
|
216
|
-
pe = eval("Pwss::" + type).new
|
217
|
-
pe.ask length, alnum
|
254
|
+
cmd = "add"
|
255
|
+
add opts, args
|
256
|
+
end
|
257
|
+
end
|
218
258
|
|
219
|
-
|
220
|
-
|
221
|
-
|
259
|
+
command :new do
|
260
|
+
banner "pwss new [options] [entry title]"
|
261
|
+
description "An alias for add"
|
222
262
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
new_string = entries.to_yaml
|
228
|
-
end
|
263
|
+
on "-f", "--filename=", "Password file to use"
|
264
|
+
on "-w", "--wait=", "Seconds password is available in the clipboard (0 = interactive)", as: Integer
|
265
|
+
|
266
|
+
on "-e", "--entry=", "Create an entry of type TYPE (Entry, CreditCard, BankAccount, SoftwareLicense).\n Default to 'Entry', which is good enough for websites credentials"
|
229
267
|
|
230
|
-
|
231
|
-
|
268
|
+
on "-g", "--generate=", "Generate a random password of given length.", as: Integer
|
269
|
+
on "-a", "--alnum", "Use only alphanumeric chars for the randomly generated password"
|
232
270
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
if pe.entry["password"]
|
237
|
-
Cipher.password_to_clipboard pe.entry["password"], waiting
|
238
|
-
end
|
271
|
+
run do |opts, args|
|
272
|
+
cmd = "new"
|
273
|
+
add opts, args
|
239
274
|
end
|
240
275
|
end
|
241
276
|
|
@@ -244,29 +279,37 @@ opts = Slop.parse :help => true do
|
|
244
279
|
banner "pwss update [options] string"
|
245
280
|
description "Update given field of user-selected entry matching <string>"
|
246
281
|
|
247
|
-
on "-f", "--filename=", "Password file to use
|
248
|
-
on "-w", "--wait=", "Seconds password is available in the clipboard (0 = interactive)
|
249
|
-
on "-g", "--generate=", "Generate a random password of given length
|
250
|
-
on "-a", "--alnum", "Use only alphanumeric chars for the randomly generated password
|
251
|
-
on
|
282
|
+
on "-f", "--filename=", "Password file to use"
|
283
|
+
on "-w", "--wait=", "Seconds password is available in the clipboard (0 = interactive)", as: Integer
|
284
|
+
on "-g", "--generate=", "Generate a random password of given length", as: Integer
|
285
|
+
on "-a", "--alnum", "Use only alphanumeric chars for the randomly generated password"
|
286
|
+
on "--field=", 'Field to update'
|
287
|
+
on "-p", "--password", "an alias for --field password"
|
252
288
|
|
253
289
|
run do |opts, args|
|
290
|
+
cmd = "update"
|
291
|
+
|
254
292
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
255
293
|
waiting = opts.to_hash[:wait] || DEFAULT_SECS
|
256
294
|
length = opts.to_hash[:generate] || 0
|
257
295
|
alnum = opts.to_hash[:alnum]
|
258
|
-
field = opts.to_hash[:field]
|
296
|
+
field = opts.to_hash[:password] ? "password" : opts.to_hash[:field]
|
297
|
+
|
298
|
+
if not field then
|
299
|
+
puts "Please specify a field to update (used --field ... or -p)"
|
300
|
+
exit 1
|
301
|
+
end
|
259
302
|
|
260
303
|
string, password = file2string filename
|
261
304
|
|
262
305
|
# load entries and update
|
263
306
|
entries = YAML::load(string) || Array.new
|
264
307
|
|
265
|
-
if field then
|
266
|
-
entries, entry_password = Pwss::update_field args.join(" "), entries, field
|
267
|
-
else
|
308
|
+
if field == "password" then
|
268
309
|
# update password
|
269
310
|
entries, entry_password = Pwss::update args.join(" "), entries, length, alnum
|
311
|
+
else
|
312
|
+
entries, entry_password = Pwss::update_field args.join(" "), entries, field
|
270
313
|
end
|
271
314
|
|
272
315
|
# check status of input file and encrypt if necessary
|
@@ -300,6 +343,8 @@ opts = Slop.parse :help => true do
|
|
300
343
|
on "-f", "--filename=", "Password file to create. Use extension '.enc' to encrypt it."
|
301
344
|
|
302
345
|
run do |opts, args|
|
346
|
+
cmd = "destroy"
|
347
|
+
|
303
348
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
304
349
|
|
305
350
|
string, password = file2string filename
|
@@ -333,6 +378,8 @@ opts = Slop.parse :help => true do
|
|
333
378
|
on "-f", "--filename=", "Password file to encrypt. Write to <file>.enc."
|
334
379
|
|
335
380
|
run do |opts, _|
|
381
|
+
cmd = "encrypt"
|
382
|
+
|
336
383
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME.sub(/\.enc$/, "")
|
337
384
|
|
338
385
|
if not File.exists?(filename)
|
@@ -364,6 +411,8 @@ opts = Slop.parse :help => true do
|
|
364
411
|
on "-f", "--filename=", "Password file to decrypt. Write to <file>, without '.enc'."
|
365
412
|
|
366
413
|
run do |opts, _|
|
414
|
+
cmd = "decrypt"
|
415
|
+
|
367
416
|
filename = opts.to_hash[:filename] || DEFAULT_FILENAME
|
368
417
|
|
369
418
|
if not File.exists?(filename)
|
@@ -380,7 +429,7 @@ opts = Slop.parse :help => true do
|
|
380
429
|
FileOps::backup dec_filename
|
381
430
|
puts "Warning: existing #{dec_filename} backupped to #{dec_filename}~"
|
382
431
|
end
|
383
|
-
|
432
|
+
|
384
433
|
FileOps::save dec_filename, decrypted
|
385
434
|
puts "A decrypted copy now lives in #{dec_filename}"
|
386
435
|
puts "You might want to check everything is ok and delete #{filename}, if you wish."
|
@@ -388,3 +437,7 @@ opts = Slop.parse :help => true do
|
|
388
437
|
end
|
389
438
|
|
390
439
|
end
|
440
|
+
|
441
|
+
if cmd == nil then
|
442
|
+
puts opts
|
443
|
+
end
|
data/lib/pwss.rb
CHANGED
@@ -93,12 +93,13 @@ module Pwss
|
|
93
93
|
end
|
94
94
|
|
95
95
|
printf "\nVarious matches." if found.size > 1
|
96
|
+
|
96
97
|
printf "\nSelect entry by ID (0..#{found.size-1}); -1 or empty string to exit: "
|
97
|
-
|
98
|
-
id =
|
98
|
+
response = Readline.readline
|
99
|
+
id = response == "" ? -1 : response.to_i
|
99
100
|
while (id < -1 or id >= found.size)
|
100
101
|
printf "Select entry by ID (0..#{found.size-1}); -1 or empty string to exit: "
|
101
|
-
response =
|
102
|
+
response = Readline.readline
|
102
103
|
id = response == "" ? -1 : response.to_i
|
103
104
|
end
|
104
105
|
if id == -1 then
|
data/lib/pwss/cipher.rb
CHANGED
@@ -10,7 +10,12 @@ module Cipher
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.decrypt string, password
|
13
|
-
|
13
|
+
begin
|
14
|
+
Encryptor.decrypt(:value => string, :key => password)
|
15
|
+
rescue Exception => e
|
16
|
+
puts "Unable to decrypt. Exiting"
|
17
|
+
exit 1
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
# Ask for a password fom the command line
|
@@ -47,17 +52,23 @@ module Cipher
|
|
47
52
|
# make the password available to the clipboard.
|
48
53
|
#
|
49
54
|
def self.password_to_clipboard password, counter = 30
|
55
|
+
old_clipboard = `pbpaste`
|
50
56
|
system("printf \"%s\" \"#{password}\" | pbcopy")
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
begin
|
59
|
+
if counter <= 0
|
60
|
+
STDIN.flush
|
61
|
+
puts "\nPassword available in clipboard: press enter when you are done."
|
62
|
+
STDIN.getc
|
63
|
+
else
|
64
|
+
puts "\nPassword available in clipboard for #{counter} seconds."
|
65
|
+
sleep(counter)
|
66
|
+
end
|
67
|
+
system("printf \"#{old_clipboard}\" | pbcopy")
|
68
|
+
rescue Exception => e
|
69
|
+
system("printf \"#{old_clipboard}\" | pbcopy")
|
70
|
+
puts "Clipboard restored. Exiting."
|
58
71
|
end
|
59
|
-
|
60
|
-
system("echo ahahahahaha | pbcopy")
|
61
72
|
end
|
62
73
|
|
63
74
|
private
|
data/lib/pwss/entry.rb
CHANGED
@@ -17,7 +17,7 @@ module Pwss
|
|
17
17
|
@entry = Hash.new
|
18
18
|
|
19
19
|
# the fields of an entry, together with:
|
20
|
-
# - the function to ask the
|
20
|
+
# - the function to ask the value
|
21
21
|
# - the default value
|
22
22
|
@fields = {
|
23
23
|
"title" => ["Readline.readline('title: ')", "'title'"],
|
@@ -32,9 +32,15 @@ module Pwss
|
|
32
32
|
|
33
33
|
# interactively ask from command line all fields specified in FIELDS
|
34
34
|
# arguments length and alnum are for password generation
|
35
|
-
def ask length = 8, alnum = true
|
35
|
+
def ask length = 8, alnum = true, overrides = {}
|
36
|
+
@fields.merge! overrides
|
36
37
|
@fields.keys.each do |key|
|
37
|
-
|
38
|
+
value = eval @fields[key][INPUT_F]
|
39
|
+
if value == nil or value == "" then
|
40
|
+
@entry[key] = eval @fields[key][DEFAULT]
|
41
|
+
else
|
42
|
+
@entry[key] = value
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
data/lib/pwss/fileops.rb
CHANGED
data/lib/pwss/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adolfo Villafiorita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.4.5
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: A password manager in the spirit of pwss
|