Created
September 8, 2014 01:49
-
-
Save redacted/ad0235ef4157e145b3b7 to your computer and use it in GitHub Desktop.
Generate an xkcd-style password with randomly capitalised letters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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