Hacking Secret Ciphers with Python

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

Practice Exercises, Chapter 1, Set A


Practice exercises can be found at http://invpy.com/hackingpractice1A.


Don’t ignore the practice exercises!


There isn’t enough room in this book to put in all the practice


exercises, but they’re still important.


You don’t become a hacker by just reading about hacking and


programming. You have to actually do it!


Doing Cryptography without Paper Tools


The cipher wheel and St. Cyr slide are nice tools to do encryption and decryption with the Caesar
cipher. But we can implement the Caesar cipher with just pencil and paper.


Write out the letters of the alphabet from A to Z with the numbers from 0 to 25 under each letter.
0 goes underneath the A, 1 goes under the B, and so on until 25 is under Z. (There are 26 letters
in the alphabet, but our numbers only go up to 25 because we started at 0, not 1.) It will end up
looking something like this:


A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12

N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25

With the above letters-to-numbers code, we can use numbers to represent letters. This is a very
powerful concept, because math uses numbers. Now we have a way to do math on letters.


Now to encrypt we find the number under the letter we wish to encrypt and add the key number
to it. This sum will be the number under the encrypted letter. For example, we encrypt, “Hello.
How are you?” with the key 13. First we find the number under the H, which is 7. Then we add
the key to this number. 7 + 13 = 20. The number 20 is under the letter U, which means the letter
H encrypts to the letter U. To encrypt the letter E, we add the 4 under E to 13 to get 17. The
number above 17 is R, so E gets encrypted to R. And so on.


This works fine until we get to the letter O. The number under O is 14. But when we add 14 + 13
we get 27. But our list of numbers only goes up to 25. If the sum of the letter’s number and the

Free download pdf