example_import.py 464 B

123456789101112131415161718
  1. import xkcdpass.xkcd_password as xp
  2. import random
  3. def random_capitalisation(s, chance):
  4. new_str = []
  5. for i, c in enumerate(s):
  6. new_str.append(c.upper() if random.random() < chance else c)
  7. return "".join(new_str)
  8. words = xp.locate_wordfile()
  9. mywords = xp.generate_wordlist(wordfile=words, min_length=5, max_length=8)
  10. raw_password = xp.generate_xkcdpassword(mywords)
  11. for i in range(5):
  12. print(random_capitalisation(raw_password, i/10.0))