Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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