[Edu-sig] Re: Edu-sig digest, Vol 1 #172 - 5 msgs
Dorothea Salo
dorothea@impressions.com
Tue, 21 Nov 2000 12:04:08 -0600
> def permute():
> """
> Randomly permute the uppercase alphabet
> by choosing its letters pseudo-randomly
> """
> alphalist = list(string.uppercase)
> newlist = []
> for i in range(len(alphalist)):
> randchar = random.choice(alphalist)
> alphalist.remove(randchar)
> newlist.append(randchar)
> return newlist
>
> def mkdict():
> """
> Pair uppercase alphabet with randomly permuted
> version of same
> """
> tuples = zip(string.uppercase,permute())
> codedict = {}
> for pair in tuples:
> codedict[pair[0]]=pair[1]
> return codedict
The above algorithms, if I'm reading them correctly, allow a character
to be substituted by itself. I assume this is desirable behavior (since it
increases the number of permutations), but perhaps someone could comment on
how often self-substitution could be expected to happen, and how likely it
might be that self-substitution would cause the "encrypted" result to be
easier to human-decode. (Self-substitution of "e" seems more likely to ease
decryption than self-substitution of "z," but I'm just guessing.)
Of course, most Cryptoquoters assume that self-substitution is
explicitly disallowed, so it might actually be considered a "feature" in
this context...
(I can think of a couple of ways to disallow self-substitution, but I
think the Python is less interesting than the problem.)
Dorothea
--
Dorothea Salo
Impressions Book and Journal Services, Inc.
phone: (608) 244-6218 fax: (608) 244-7050
http://www.impressions.com