Generate passwords that can easily be typed with only the left hand, very simple script
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 | #!/usr/bin/python
import argparse
import random
parser = argparse.ArgumentParser(description='Generate a left-handed random password.')
parser.add_argument('-n', action='store', dest='passNum', default=8, type=int, help='Number of passwords to generate.')
parser.add_argument('-l', action='store', dest='passLen', default=8, type=int, help='Length of password')
parser.add_argument('-s', action='store', dest='passStrength', default=4, type=int, help='Strength of password (1-4)')
lowerChars = "qwertasdfgzxcvb"
upperChars = "QWERTASDFGZXCVB"
lowerNum = "123456"*3 # repeated digits for 'weight'
upperNum = '!"$%^'*3
results=parser.parse_args()
#Generate character to select from according to passStrength (-s)
if results.passStrength == 1:
leftHand = lowerChars
elif results.passStrength == 2:
leftHand = lowerChars+upperChars
elif results.passStrength == 3:
leftHand = lowerChars+upperChars+lowerNum
elif results.passStrength == 4:
leftHand = lowerChars+upperChars+lowerNum+upperNum
for i in range(results.passNum):
leftPass = ''
for j in range(results.passLen):
leftPass = leftPass + leftHand[random.randint(0,len(leftHand)-1)]
print leftPass
|
Pretty funny. I really like the intent of this recipe.
Have you considered using other functions of
random
module, such aschoice
orsample
?Thanks obernard :) Haha, the intention of this script was entirely innocent since I am left-handed, however my friend soon pointed out how it would be useful to the right-handed population and hence how it ended up here ;D
I like it it is very cool.
I have a friend who lost his left hand in an industrial accident. Can he use his right hand to type the left-handed password?
<tongue firmly in cheek>
Great example code.