Skip to content

Instantly share code, notes, and snippets.

@markjenkins
Last active Oct 8, 2021
Embed
What would you like to do?
wordlist based password generators
#!/usr/bin/env python3
from __future__ import print_function
from random import SystemRandom
from os.path import join, dirname
sysrandom = SystemRandom()
NUM_WORDS = 4
with open( join(dirname(__file__), 'wordlist.txt') ) as f:
words = [word.strip() for word in f]
print(' '.join( sysrandom.choice(words) for x in range(NUM_WORDS) ) )
#!/usr/bin/env python3
from __future__ import print_function
from random import SystemRandom
from os.path import join, dirname
from sys import argv
sysrandom = SystemRandom()
try:
NUM_WORDS = int(argv[1])
except ValueError:
NUM_WORDS = 4
except IndexError:
NUM_WORDS = 4
with open( join(dirname(__file__), 'wordlist.txt') ) as f:
words = [word.strip() for word in f]
print(' '.join( sysrandom.choice(words) for x in range(NUM_WORDS) ) )
#!/usr/bin/env python
from __future__ import print_function
from random import SystemRandom
from os.path import join, dirname
from sys import argv
sysrandom = SystemRandom()
NUM_WORDS = int(argv[1])
with file( argv[2] ) as f:
words = [word.strip() for word in f]
print(' '.join( sysrandom.choice(words) for x in xrange(NUM_WORDS) ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment