Skip to content

Instantly share code, notes, and snippets.

@redacted
Created September 8, 2014 01:49
Show Gist options
  • Save redacted/ad0235ef4157e145b3b7 to your computer and use it in GitHub Desktop.
Save redacted/ad0235ef4157e145b3b7 to your computer and use it in GitHub Desktop.
Generate an xkcd-style password with randomly capitalised letters
import random
from xkcdpass.xkcd_password import *
def random_capitalisation(s, chance):
new_str = []
for i, c in enumerate(s):
new_str.append(c.upper() if random.random() < chance else c)
return "".join(new_str)
words = "/usr/share/dict/words"
mywords = generate_wordlist(wordfile=words, min_length=5, max_length=8)
raw_password = generate_xkcdpassword(mywords)
for i in range(5):
print random_capitalisation(raw_password, i/10.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment