Skip to content

Instantly share code, notes, and snippets.

@UnixSage
Last active December 31, 2019 15:24
Show Gist options
  • Save UnixSage/5fabb133fee29bdffb50e2ef199bb923 to your computer and use it in GitHub Desktop.
Save UnixSage/5fabb133fee29bdffb50e2ef199bb923 to your computer and use it in GitHub Desktop.
Generate random word password that are "Datacenter Compatable" meaning realistically typable into a console.
#!/usr/bin/env python3
from random import choice,shuffle
import string
password=[]
words=[]
shortwords=[]
wordfile=open("/usr/share/dict/words")
for word in wordfile:
word=word.strip(string.punctuation)
word=word.strip(string.digits)
word=word.capitalize()
word=word.strip()
if len(word) > 7:
words.append(word)
else:
shortwords.append(word)
wordfile.close
shuffle(shortwords)
newword=""
for word in shortwords:
newword=newword+word
if len(newword) > 9:
words.append(newword)
newword=""
print("Word Pool Size: %s" % (len(words)))
password.append(choice(words))
password.append(choice(string.punctuation))
password.append(choice(string.digits))
password.append(choice(string.digits))
password.append(choice(words))
print("".join(password))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment