Guest User

Untitled

a guest
Sep 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import string
  2. import random
  3.  
  4.  
  5. def strong_pass():
  6. pass_len = 20
  7. poss_char = string.ascii_letters + string.digits + string.punctuation
  8. return ''.join(random.choices(poss_char, k=pass_len))
  9.  
  10.  
  11. def weak_pass():
  12. with open('16.words_alpha.txt', "r") as dict_words:
  13. words = [word.strip() for word in dict_words.readlines()]
  14. return ' '.join(random.sample(words, 2))
  15.  
  16.  
  17. def get_mode():
  18. while True:
  19. input_text = "Type 'w' for a weak password or 's' for a strong one: "
  20. tmp = input(input_text).lower()
  21. if tmp in ['w', 's']:
  22. return tmp
  23.  
  24.  
  25. def main():
  26. tmp = get_mode()
  27. if tmp == "w":
  28. print(weak_pass())
  29. else:
  30. print(strong_pass())
  31.  
  32.  
  33. if __name__ == '__main__':
  34. main()
Add Comment
Please, Sign In to add comment