This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassphrase
executable file
·71 lines (69 loc) · 3.06 KB
/
passphrase
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# - May you do good and not evil.
# - May you find forgiveness for yourself and forgive others.
# - May you share freely, never taking more than you give.
#
import random, sys, getopt
def main(argv):
words = [s.split()[1] for s in open(sys.path[0]+'/words')]
vorvig = [s.split()[0] for s in open(sys.path[0]+'/words-vorvig')]
short = [s.split()[1] for s in open(sys.path[0]+'/words-short-memorable')]
edit = [s.split()[1] for s in open(sys.path[0]+'/words-short-edit')]
beale = [s.split()[1] for s in open(sys.path[0]+'/words-beale')]
p = words
n = range(5)
try:
opts, args = getopt.getopt(argv,"hbwvsen:",["beale","words","vorvig","number","short","edit", "help"])
except Exception as e:
print e
print 'To get help, run $ ./passphrase -h or $ ./passphrase --help'
sys.exit(2)
for opt, arg in opts:
if opt in ('-h', '--help'):
print '# Version: diceware-password-generator 1.0.3'
print '# Release Date: 21 March 2018'
print '# Project: https://justin.hartman.me/projects/diceware-password-generator.html'
print '#'
print '# The author disclaims copyright to this source code. In place of'
print '# a legal notice, here is a blessing:'
print '#'
print '# - May you do good and not evil.'
print '# - May you find forgiveness for yourself and forgive others.'
print '# - May you share freely, never taking more than you give.'
print '#'
print 'Usage: $ ./passphrase [options] [-n] <number of words>'
print 'Options:'
print '-w, --words Standard word list (default list)'
print '-v, --vorvig Vorvig word list'
print '-s, --short Short, memorable word list'
print '-e, --edit Short, editable word list. Experimental.'
print '-b, --beale Beale Diceware word list.'
print '--------------------------------------------------------'
print '-n, --number Input an integer for the number of words'
print ' you want generated for your passphrase.'
print ''
print 'Example: $ ./passphrase'
print 'Example: $ ./passphrase --words'
print 'Example: $ ./passphrase -w'
print 'Example: $ ./passphrase --words -n 4'
print 'Example: $ ./passphrase -w -n 4'
sys.exit(2)
elif opt in ("-w", "--words"):
p = words
elif opt in ("-b", "--beale"):
p = beale
elif opt in ("-v", "--vorvig"):
p = vorvig
elif opt in ("-s", "--short"):
p = short
elif opt in ("-e", "--edit"):
p = edit
if opt in ("-n", "--number"):
n = range(int(arg))
print '-'.join(random.SystemRandom().choice(p) for i in n)
if __name__ == "__main__":
main(sys.argv[1:])