Skip to content

Instantly share code, notes, and snippets.

@rinchik
Last active June 11, 2016 19:43
Show Gist options
  • Save rinchik/66702245a0f79ff4fbe731748269b275 to your computer and use it in GitHub Desktop.
Save rinchik/66702245a0f79ff4fbe731748269b275 to your computer and use it in GitHub Desktop.
Python string permutations to generate all possible password variations with given length and known characters
from datetime import datetime
startTime = datetime.now()
password = "abba"
character_list = 'abcdefghijklmnopqrstuvwxyz'
a = []
for current in xrange(len(password)):
a = [i for i in character_list]
for y in xrange(current):
a = [x+i for i in character_list for x in a]
print "We generated all possible passwords in", datetime.now() - startTime
print "Our password is", a.index(password), "in the list of all passwords"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment