Hacking Secret Ciphers with Python

(Ann) #1
Chapter 1 – Making Paper Cryptography Tools 13

To decrypt, you will have to understand what negative numbers are. If you don’t know how to
add and subtract with negative numbers, there is a tutorial on it here: http://invpy.com/neg.


To decrypt, subtract the key instead of adding it. For the ciphertext letter B, the number is 1.
Subtract 1 – 13 to get -12. Like our “subtract 26” rule for encrypting, when we are decrypting and
the result is less than 0, we have an “add 26” rule. -12 + 26 is 14. So the ciphertext letter B
decrypts back to letter O.


Table 1-2. The steps to decrypt the ciphertext with paper and pencil.
Ciphertext
Letter

Ciphertext
Number


  • Key Result Add
    26?


Result Plaintext
Letter
U 20 - 13 = 7 = 7 7 = H
R 17 - 13 = 4 = 4 4 = E
Y 24 - 13 = 11 = 11 11 = L
Y 24 - 13 = 11 = 11 11 = L
B 1 - 13 = - 12 + 26 = 1 4 14 = O

U 20 - 13 = 7 = 7 7 = H
B 1 - 13 = - 12 + 26 = 14 14 = O
J 9 - 13 = - 4 + 26 = 22 22 = W

N 13 - 13 = 0 = 0 0 = A
E 4 - 13 = - 9 + 26 = 17 17 = R
R 17 - 13 = 4 = 4 4 = E

L 11 - 13 = - 2 + 26 = 24 24 = Y
B 1 - 13 = - 12 + 26 = 14 14 = O
H 7 - 13 = - 6 + 26 = 20 20 = U

As you can see, we don’t need an actual cipher wheel to do the Caesar cipher. If you memorize
the numbers and letters, then you don’t even need to write out the alphabet with the numbers
under them. You could just do some simple math in your head and write out secret messages.


Practice Exercises, Chapter 1, Set B


Practice exercises can be found at http://invpy.com/hackingpractice 1 B.


Double-Strength Encryption?.....................................................................................................................................


You might think that encrypting a message twice with two different keys would double the
strength of our encryption. But this turns out not to be the case with the Caesar cipher (and most
other ciphers). Let’s try double-encrypting a message to see why.

Free download pdf