Skip to content

Instantly share code, notes, and snippets.

@phoexer
Created June 20, 2020 15:51
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 phoexer/da3d4c7d16033c949d4bdf583d306f6d to your computer and use it in GitHub Desktop.
Save phoexer/da3d4c7d16033c949d4bdf583d306f6d to your computer and use it in GitHub Desktop.
Generate Potential Passwords
def generate_words(template):
word_list = []
while len(template) > 0:
if template[0] == '[':
index = template.index(']')
options = list(template[1: index])
if len(options) == 1:
options.append('')
new_word_list = []
for option in options:
word_list_tmp = [s + option for s in word_list]
if len(word_list_tmp) == 0:
word_list_tmp.append(option)
new_word_list += word_list_tmp
word_list = new_word_list
template = template[index + 1:]
else:
try:
index = template.index('[')
except ValueError:
index = len(template)
prefix = template[0: index]
new_word_list = [s + prefix for s in word_list]
if len(new_word_list) == 0:
new_word_list.append(prefix)
word_list = new_word_list
template = template[index:]
return word_list
template = "Th[3e]QuickbR[oO0]WNF[o0]xDi[e3]dpAINFULLY."
word_list = generate_words(template)
for word in word_list:
print(word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment