Skip to content

Instantly share code, notes, and snippets.

@markjenkins
Last active October 8, 2021 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markjenkins/e08fbed431fee03135bcb10283a8fcf8 to your computer and use it in GitHub Desktop.
Save markjenkins/e08fbed431fee03135bcb10283a8fcf8 to your computer and use it in GitHub Desktop.
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