Hacking Secret Ciphers with Python

(Ann) #1

14 http://inventwithpython.com/hacking


Email questions to the author: [email protected]


If we encrypt the word “KITTEN” with the key 3, the resulting cipher text would be
“NLWWHQ”. If we encrypt the word “NLWWHQ” with the key 4, the resulting cipher text of
that would be “RPAALU”. But this is exactly the same as if we had encrypted the word
“KITTEN” once with a key of 7. Our “double” encryption is the same as normal encryption, so it
isn’t any stronger.


The reason is that when we encrypt with the key 3, we are adding 3 to plaintext letter’s number.
Then when we encrypt with the key 4, we are adding 4 to the plaintext letter’s number. But
adding 3 and then adding 4 is the exact same thing as adding 7. Encrypting twice with keys 3 and
4 is the same as encrypting once with the key 7.


For most encryption ciphers, encrypting more than once does not provide additional
strength to the cipher. In fact, if you encrypt some plaintext with two keys that add up to 26, the
ciphertext you end up with will be the same as the original plaintext!


Programming a Computer to do Encryption


The Caesar cipher, or ciphers like it, were used to encrypt secret information for several centuries.
Here’s a cipher disk of a design invented by Albert Myer that was used in the American Civil
War in 1863.


Figure 1-13. American Civil War Union Cipher Disk at the National Cryptologic Museum.

If you had a very long message that you wanted to encrypt (say, an entire book) it would take you
days or weeks to encrypt it all by hand. This is how programming can help. A computer could do

Free download pdf