Advertisement
tryingtoshare

random password generator

May 20th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import sys
  2. import random
  3.  
  4. def generatepwd(length):
  5.     print type(length)
  6.     #output = 'miamcomicalhostagi#cpasswordphrase'[1:length]
  7.     outputlist = getasciichars()
  8.     outputstring = ''.join(outputlist)
  9.     return outputstring
  10.  
  11. def getasciichars():
  12.     mylist = []
  13.     for x in range(32,126):
  14.         mylist.append(ord(chr(x)))
  15.     print mylist
  16.     print '[%s]' % ', '.join(map(str, mylist))
  17.     outputlist = []
  18.     for x in range(0,length):
  19.         outputlist.append(chr(random.choice(mylist)))
  20.     return outputlist
  21.  
  22.  
  23. if len(sys.argv) > 1:
  24.     length = int(sys.argv[1])
  25.     if length < 8:
  26.         length = 8
  27.     elif length > 20:
  28.         length = 20
  29. else:
  30.     length = 8
  31.  
  32. print "Length of password " + str(length) + " password " + generatepwd(length)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement