[Tutor] All possible 16 character alphanumeric strings?
Joel Goldstick
joel.goldstick at gmail.com
Sun Sep 16 01:12:04 CEST 2012
On Sat, Sep 15, 2012 at 6:50 PM, Scurvy Scott <etanes.rm at gmail.com> wrote:
> Hello again python tutor list.
> I have what I see as a somewhat complicated problem which I have no idea
> where to begin. I'm hoping you fine folks can help me.
>
> I'm trying to generate a list of every possible 16 character string
> containing only 2-7 and a-z lowercase. I've seen some examples using regex
> to define which characters I want to use but not a way to generate the
> complete list of all possibilities. I'm not looking for a handout- just a
> point in the right direction.
>
> Any information would be awesome, thanks.
>
> Right now I've got something like:
>
> import random
>>>> ''.join(random.choice('234567abcdefghijklmnopqrstuvwxyz') for i in
>>>> range(16))
>
>
> Which only prints 1 number, obviously.
>
> or possibly something like this:
>
>
> def genKey():
>
> hash = hashlib.md5(RANDOM_NUMBER).digest().encode("base32")
>
> alnum_hash = re.sub(r'[^a-z2-7]', "", hash)
>
> return alnum_hash[:16]
>
>
> Keeping in mind that although I understand this code, I did not write it, I
> got it from stackoverflow.
>
> Again any help would be great. Feel free to ask if you must know exactly
> what I'm trying to do.
>
check this out:
http://stackoverflow.com/questions/104420/how-to-generate-all-permutations-of-a-list-in-python
--
Joel Goldstick
More information about the Tutor
mailing list