# Freeman Lo # # Generating a password randomly from a list of characters # # # updated the mechanism on character processing # v0.0.2 ########################################################## import md5 import random import string def main(): #alias r = random # setting up the characters mess = "" mess = string.digits mess = mess + string.ascii_uppercase mess = mess + string.ascii_lowercase mess = mess + string.punctuation # the list of alfa-numeric characters list = [] for i in mess: list.append(i) # initialization word = "" pword = "" tmp = cnt = 0 # randomly generate a number and select a character which matches the list # and it concartnates into a string variable. while cnt < 10: r.seed(r.random()) tmp = r.randint(0, len(list)-1) word = str(list[tmp]) pword = pword + word cnt = cnt + 1 print "\n" print "Password is: " + pword + "\n" main()