# # Freeman Lo # Generating a password randomly from a list of characters # # I was hoping to use md5 to generate a hash md5 of the password. # # To demonstrate to students the power of python, # encourage coding to solve real life problems ########################################### #libraries import md5, random def main(): #alias r=random # the list of alfa-numeric characters list = [1,2,3,4,5,6,7,8,9,0,'a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','q','r', 's','t','u','v','w','x','y','z','A','B','C','D', 'E','F','G','H','I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X','Y','Z','?','$','@','='] # 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, 65) word = str(list[tmp]) pword = pword + word cnt = cnt + 1 print pword main()