Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import random
  3. import string
  4. def ask():
  5. options = ["weak", "strong"]
  6. user = input("Do you want a weak or strong password? ")
  7. if user.lower() in options:
  8. return user
  9. else:
  10. print("you have not entered 'weak' or 'strong'")
  11. ask()
  12.  
  13. def weak():
  14. dictionary = ["dog", "cat"]
  15. max = int(len(dictionary)) - 1
  16. select = random.randint(0, max)
  17. select2 = random.randint(0, max)
  18. wpassword = dictionary[select] + dictionary[select2]
  19. print(wpassword)
  20.  
  21. def strong():
  22. x = random.randint(6, 15)
  23. y = 0
  24. pas = []
  25. while x > 0:
  26. ran = random.choice(string.ascii_lowercase + string.digits + string.ascii_uppercase + string.punctuation)
  27. pas.append(ran)
  28. x -= 1
  29. spassword = ''.join(pas)
  30. print(spassword)
  31.  
  32. def gen():
  33. if ask() == "weak":
  34. weak()
  35. else:
  36. strong()
  37. gen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement