Caesar Cypher |
One of the earliest encrypting systems is attributed to Julius Caesar: if the letter to be encrypted is the Nth letter in the alphabet, replace it with the (N+K)th where K is some fixed integer (Caesar used K = 3). We usually treat a space as zero and all arithemtic is then done modulo 27. Thus for K = 1 the message `ATTACK AT DAWN' becomes `BUUBDLABUAEBXO'.
Decrypting such a message is trivial since one only needs to try 26 different
values of K. This
process is aided by knowledge of the language, since then one can determine
when the decrypted
text forms recognisable words. If one does not know the language, then a
dictionary would be necessary.
Write a program that will read in a dictionary and some encrypted text,
determine the value of K
that was used, and then decrypt the cyphertext to produce the original
message. The original
message contained only letters and spaces and has been encrypted using the
above method. The
most suitable value of K will be the one which produces the most matches with
the words in the dictionary.
THIS DAWN THAT THE ZORRO OTHER AT THING # BUUBDLA PSSPABUAEBXO
ATTACK ZORRO AT DAWN