Skip to content

Instantly share code, notes, and snippets.

@mplovepop
Created April 2, 2019 22:02
Show Gist options
  • Save mplovepop/bc4a9b5bd89cdf1d02ba4b27db8d0f5b to your computer and use it in GitHub Desktop.
Save mplovepop/bc4a9b5bd89cdf1d02ba4b27db8d0f5b to your computer and use it in GitHub Desktop.
~/.local/bin/mkpass
#!/usr/bin/python
import os, sys, random, string
length = int(sys.argv[1]) if len(sys.argv) > 1 else 4
if length < 8:
with open('/usr/share/dict/words', 'r') as f:
choice_list = [l.strip() for l in f.readlines()]
ch = ' '
else:
choice_list = string.ascii_letters + string.digits + '!@#$%^&*()'
ch = ''
random.seed = (os.urandom(1024))
print ch.join(random.choice(choice_list) for i in range(length))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment