Your Ad Here

Posted By

p1p1092 on 02/10/12


Tagged

password python generator


Versions (?)

Python Password Generator


 / Published in: Python
 

A simple python password generator...

  1. import string
  2. import random
  3.  
  4. def main():
  5. while True:
  6. stop = input("Generate password? y/n: ")
  7. if stop and stop[0].lower() == "n":
  8. break
  9.  
  10. length = int
  11.  
  12. size = input("What length do you want the password to be(4-20): ")
  13. if size == "4":
  14. length = 4
  15. if size == "5":
  16. length = 5
  17. if size == "6":
  18. length = 6
  19. if size == "7":
  20. length = 7
  21. if size == "8":
  22. length = 8
  23. if size == "9":
  24. length = 9
  25. if size == "10":
  26. length = 10
  27. if size == "11":
  28. length = 11
  29. if size == "12":
  30. length = 12
  31. if size == "13":
  32. length = 13
  33. if size == "14":
  34. length = 14
  35. if size == "15":
  36. length = 15
  37. if size == "16":
  38. length = 16
  39. if size == "17":
  40. length = 17
  41. if size == "18":
  42. length = 18
  43. if size == "19":
  44. length = 19
  45. if size == "20":
  46. length = 20
  47. else:
  48. length = 6
  49.  
  50. chars = string.ascii_letters + string.digits
  51. return ''.join(random.choice(chars) for x in range(length))

Report this snippet  

You need to login to post a comment.