[Tutor] Clunky Password maker

Wolf Halton wolf.halton at gmail.com
Wed May 25 19:25:59 CEST 2011


Is there a less clunky way to do this?
[code]
def new_pass():
    series = ['`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-',
'=', \
              '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_',
'+', \
              'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
'\\', \
              'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}',
'|', \
              'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', "'", \
              'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', \
              'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', \
              'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?']
    passwd = []
    p = input("Enter the length you want your password to be: ")
              # length of password
    for i in range(p):
        r = random.randint(0, 94)
        passwd.append(series[r]) # Append a random char from series[] to
passwd
    #print passwd
    #print passwd[0], passwd[1], passwd[2], passwd[3]
    print ""
    print "".join(map(str, passwd)), " is your new password. \n"
[/code]

[output]
>>>
Enter 1 to run a MD5    hash on your password
Enter 2 to run a SHA1   hash on your password
Enter 3 to run a SHA224 hash on your password
Enter 9 to get a new randomy password
Enter 10 to run away...  he he he

Enter your choice here> 9
Enter the length you want your password to be: 4

!bnR  is your new password.
>>>
[/output]

-- 
This Apt Has Super Cow Powers - http://sourcefreedom.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110525/5f864fe0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashy.py
Type: application/octet-stream
Size: 2808 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20110525/5f864fe0/attachment-0001.obj>


More information about the Tutor mailing list