[Tutor] All possible 16 character alphanumeric strings?

Scurvy Scott etanes.rm at gmail.com
Sun Sep 16 04:58:42 CEST 2012


possible = "234567abcdefghijklmnopqrstuvwxyz"
word_length = 16
print 'Running "every.py"'
word_list = []
def add_word(word):
    if len(word)==word_length:
        word_list.append(word)
        print word
    else:
        for c in possible:
            new_word = word + c
            add_word(new_word)


The only problem with this code is that it actually takes a word as its
input and just checks that it is == word length. If not it just appends the
string possible to the variable word that was called in the function
add_word.

I need to be able to generate every possible combination of the characters
in the variable possible, ideally coming up with a string that resembles
the TOR hidden network strings that look like this: "kpvz7ki2v5agwt35.onion"


Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120915/03880452/attachment.html>


More information about the Tutor mailing list