Newbie: Python & ADFGVX Cipher Cracking?

Gandalf gandalf at geochemsource.com
Wed Nov 17 09:48:24 EST 2004


>
> The characters "ABC" can be re-arranged in several different possible 
> ways:
>
> 1) ABC
> 2) BAC
> 3) BCA
> 4) ACB
> 5) CAB
> 6) CBA
>
> Is there a python function in which I can sent a string of characters 
> to -- and it will provide me with a list of all possible combinations 
> available?
>
> example function call:   possCharList = allCombinations("ABC")
>
> Any help SINCERELY appreciated!! 

I do not this this would be an effective way. The number of the 
permutation for n characters is n factorial.
For a cipher with a block size of 10, the number of permutations is 10! 
=  3628800.
You do not really want to have a list with 3628800 elements. :-)
You should better create an iterator for this, that can loop over the 
elements. (E.g. given a permutation,
it calculates the next permutation.) Do not store all elements in memory.




More information about the Python-list mailing list