|
@@ -12,6 +12,7 @@ targetLen = 20 # default pw len
|
|
useConjunction = False
|
|
useConjunction = False
|
|
number = 1
|
|
number = 1
|
|
punc = " !@#$%^&*()-_=+[{]}\|;:/?.>,<`~"
|
|
punc = " !@#$%^&*()-_=+[{]}\|;:/?.>,<`~"
|
|
|
|
+number_punc = "0123456789"
|
|
|
|
|
|
def toInt(s, chkRange, errStr = "sorry, that's not a number", rangeStr = "sorry, I can't do that number"):
|
|
def toInt(s, chkRange, errStr = "sorry, that's not a number", rangeStr = "sorry, I can't do that number"):
|
|
try:
|
|
try:
|
|
@@ -27,12 +28,14 @@ def toInt(s, chkRange, errStr = "sorry, that's not a number", rangeStr = "sorry,
|
|
narg = 1
|
|
narg = 1
|
|
if len(sys.argv)>1:
|
|
if len(sys.argv)>1:
|
|
if sys.argv[1]=="-h" or sys.argv[1]=="--help":
|
|
if sys.argv[1]=="-h" or sys.argv[1]=="--help":
|
|
- print "pwgen.py v1.2 generate passphrase; inspired by xkcd/936 and SteveGibson\n"
|
|
|
|
- print "Usage: pwgen.py [-p | -P] [length [num_phrases]] "
|
|
|
|
|
|
+ print "pwgen.py v1.3 generate passphrase; inspired by xkcd/936 and SteveGibson\n"
|
|
|
|
+ print "Usage: pwgen.py [-p | -P | -n ] [length [num_phrases]] "
|
|
print " pwgen.py -c [num_phrases]"
|
|
print " pwgen.py -c [num_phrases]"
|
|
print " pwgen.py -h | --help \n"
|
|
print " pwgen.py -h | --help \n"
|
|
print " -p pad with only spaces (for smartphone)"
|
|
print " -p pad with only spaces (for smartphone)"
|
|
print " -P pad with spaces, period and comma (for smartphone)"
|
|
print " -P pad with spaces, period and comma (for smartphone)"
|
|
|
|
+ print " -n pad with numbers"
|
|
|
|
+ print " -N pad with numbers, spaces, period, comma like -P -n"
|
|
print " length make pass phrases padded with punctuation filler; default=20"
|
|
print " length make pass phrases padded with punctuation filler; default=20"
|
|
print " -c make 2 word pass phrases with a conjuction filler"
|
|
print " -c make 2 word pass phrases with a conjuction filler"
|
|
print " num_phrases make multiple pass phrases, one per line; default=1\n"
|
|
print " num_phrases make multiple pass phrases, one per line; default=1\n"
|
|
@@ -40,6 +43,12 @@ if len(sys.argv)>1:
|
|
elif sys.argv[1]=="-c": # conjunction mode
|
|
elif sys.argv[1]=="-c": # conjunction mode
|
|
useConjunction = True
|
|
useConjunction = True
|
|
narg = narg + 1
|
|
narg = narg + 1
|
|
|
|
+ elif sys.argv[1]=='-n': # number fill mode
|
|
|
|
+ punc = number_punc
|
|
|
|
+ narg = narg + 1
|
|
|
|
+ elif sys.argv[1]=='-N':
|
|
|
|
+ punc = number_punc + " ,."
|
|
|
|
+ narg = narg + 1
|
|
elif sys.argv[1]=="-p": # use only space
|
|
elif sys.argv[1]=="-p": # use only space
|
|
punc = " "
|
|
punc = " "
|
|
narg = narg + 1
|
|
narg = narg + 1
|
|
@@ -79,7 +88,7 @@ for i in range(number):
|
|
|
|
|
|
if useConjunction == False:
|
|
if useConjunction == False:
|
|
if whole + 6 >= targetLen: # if 2 words is enough
|
|
if whole + 6 >= targetLen: # if 2 words is enough
|
|
- r = targetLen - whole
|
|
|
|
|
|
+ r = max(1,targetLen - whole)
|
|
pw = w[0] + thisPunct*r + w[1]
|
|
pw = w[0] + thisPunct*r + w[1]
|
|
else: # otherwise use 3
|
|
else: # otherwise use 3
|
|
whole = whole + len(w[2])
|
|
whole = whole + len(w[2])
|
|
@@ -93,7 +102,7 @@ for i in range(number):
|
|
if conj[-2:]==" a":
|
|
if conj[-2:]==" a":
|
|
conj = conj+'n'
|
|
conj = conj+'n'
|
|
pw = w[0] + ' ' + conj + ' ' + w[1]
|
|
pw = w[0] + ' ' + conj + ' ' + w[1]
|
|
-
|
|
|
|
|
|
+
|
|
print pw
|
|
print pw
|
|
|
|
|
|
|
|
|