Hacking with python for beginners

hacking with python programming how to make hacking software in python and how to start hacking with python
ImogenCameron Profile Pic
Published Date:14-07-2017
Your Website URL(Optional)
Hacking Secret Ciphers with Python By Al Sweigart 2 http://inventwithpython.com/hacking What is Cryptography? Look at the following two pieces of text: “Zsijwxyfsi niqjsjxx gjyyjw. Ny nx jnymjw ktqqd tw “Flwyt tsytbbnz jqtw yjxndwri iyn fqq knqrqt xj mh bnxitr; ny nx anwyzj ns bjfqym fsi anhj ns utajwyd. ndyn jxwqswbj. Dyi jjkxxx sg ttwt gdhz js jwsn; Ns ymj bnsyjw tk tzw qnkj, bj hfs jsotd ns ujfhj ymj wnjyiyb aijnn snagdqt nnjwww, xstsxsu jdnxzz xkw kwznyx bmnhm ns nyx xuwnsl tzw nsizxywd uqfsyji. znfs uwwh xni xjzw jzwyjy jwnmns mnyfjx. Stjj wwzj Htzwynjwx tk lqtwd, bwnyjwx tw bfwwntwx, xqzrgjw ti fnu, qt uyko qqsbay jmwskj. Sxitwru nwnqn nx ujwrnyyji dtz, gzy tsqd zuts qfzwjqx.” nxfzfbl yy hnwydsj mhnxytb myysyt.” The text on the left side is a secret message. The message has been encrypted, or turned into a secret code. It will be completely unreadable to anyone who doesn’t know how to decrypt it (that is, turn it back into the plain English message.) This book will teach you how to encrypt and decrypt messages. The message on the right is just random gibberish with no hidden meaning whatsoever. Encrypting your written messages is one way to keep them secret from other people, even if they get their hands on the encrypted message itself. It will look exactly like random nonsense. Cryptography is the science of using secret codes. A cryptographer is someone who uses and studies secret codes. This book will teach you what you need to know to become a cryptographer. Of course, these secret messages don’t always stay secret. A cryptanalyst is someone who can hack secret codes and read other people’s encrypted messages. Cryptanalysts are also called code breakers or hackers. This book will also teach you what you need to know to become a cryptanalyst. Unfortunately the type of hacking you learn in this book isn’t dangerous enough to get you in trouble with the law. (I mean, fortunately.) Spies, soldiers, hackers, pirates, royalty, merchants, tyrants, political activists, Internet shoppers, and anyone who has ever needed to share secrets with trusted friends have relied on cryptography to make sure their secrets stay secret. Codes vs. Ciphers th The development of the electric telegraph in the early 19 century allowed for near-instant communication through wires across continents. This was much faster than sending a horseback rider carrying a bag of letters. However, the telegraph couldn’t directly send written letters drawn on paper. Instead it could send electric pulses. A short pulse is called a “dot” and a long pulse is called a “dash”. Email questions to the author: alinventwithpython.comChapter 1 – Making Paper Cryptography Tools 3 Figure 1-1. Samuel Morse Figure 1-2. Alfred Vail April 27, 1791 – April 2, 1872 September 25, 1807 – January 18, 1859 In order to convert these dots and dashes to A ● ▬ T ▬ B ▬ ● ● ● U ● ● ▬ English letters of the alphabet, an encoding C ▬ ● ▬ ● V ● ● ● ▬ system (or code) is needed to translate from D ▬ ● ● W ● ▬ ▬ English to electric pulse code (called ● ▬ ● ● ▬ E X encoding) and at the other end translate F ● ● ▬ ● Y ▬ ● ▬ ▬ electric pulses to English (called decoding). G ▬ ▬ ● Z ▬ ▬ ● ● The code to do this over telegraphs (and later, H ● ● ● ● I ● ● radio) was called Morse Code, and was J ● ▬ ▬ ▬ 1 ● ▬ ▬ ▬ ▬ developed by Samuel Morse and Alfred Vail. K ▬ ● ▬ 2 ● ● ▬ ▬ ▬ By tapping out dots and dashes with a one- ● ▬ ● ● ● ● ● ▬ ▬ L 3 button telegraph, a telegraph operator could M ▬ ▬ 4 ● ● ● ● ▬ communicate an English message to someone N ▬ ● 5 ● ● ● ● ● on the other side of the world almost instantly O ▬ ▬ ▬ 6 ▬ ● ● ● ● (If you’d like to learn Morse code, visit P ● ▬ ▬ ● 7 ▬ ▬ ● ● ● http://invpy.com/morse.) Q ▬ ▬ ● ▬ 8 ▬ ▬ ▬ ● ● R ● ▬ ● 9 ▬ ▬ ▬ ▬ ● S ● ● ● 0 ▬ ▬ ▬ ▬ ▬ Figure 1-3. International Morse Code, with characters represented as dots and dashes. Codes are made to be understandable and publicly available. Anyone should be able to look up what a code’s symbols mean to decode an encoded message. Making a Paper Cipher Wheel Before we learn how to program computers to do encryption and decryption for us, let’s learn how to do it ourselves with simple paper tools. It is easy to turn the understandable English text (which is called the plaintext) into the gibberish text that hides a secret code (called the 4 http://inventwithpython.com/hacking ciphertext). A cipher is a set of rules for converting between plaintext and ciphertext. These rules often use a secret key. We will learn several different ciphers in this book. Let’s learn a cipher called the Caesar cipher. This cipher was used by Julius Caesar two thousand years ago. The good news is that it is simple and easy to learn. The bad news is that because it is so simple, it is also easy for a cryptanalyst to break it. But we can use it as a simple learning exercise. More information about the Caesar cipher is given on Wikipedia: http://en.wikipedia.org/wiki/Caesar_cipher. To convert plaintext to ciphertext using the Caesar cipher, we will create something called a cipher wheel (also called a cipher disk). You can either photocopy the cipher wheel that appears in this book, or print out the one from http://invpy.com/cipherwheel. Cut out the two circles and lay them on top of each other like in Figure 1-8. Email questions to the author: alinventwithpython.comChapter 1 – Making Paper Cryptography Tools 7 Figure 1-6. Cutting out Figure 1-8. The Figure 1-7. The cut-out circles. the cipher wheel completed cipher circles. wheel. After you cut out the circles, place the smaller one in the middle of the larger one. Put a pin or brad through the center of both circles so you can spin them around in place. You now have a tool for creating secret messages with the Caesar cipher. A Virtual Cipher Wheel There is also a virtual cipher wheel online if you don’t have scissors and a photocopier handy. Open a web browser to http://invpy.com/cipherwheel to use the software version of the cipher wheel. To spin the wheel around, click on it with the mouse and then move the mouse cursor around until the key you want is in place. Then click the mouse again to stop the wheel from spinning. Figure 1-9. The online cipher wheel. 8 http://inventwithpython.com/hacking How to Encrypt with the Cipher Wheel First, write out your message in English on paper. For this example we will encrypt the message, “The secret password is Rosebud.” Next, spin the inner wheel around until its letters match up with letters in the outer wheel. Notice in the outer wheel there is a dot next to the letter A. Look at the number in the inner wheel next to the dot in the outer wheel. This number is known the encryption key. The encryption key is the secret to encrypting or decrypting the message. Anyone who reads this book can learn about the Caesar cipher, just like anyone who reads a book about locks can learn how a door lock works. But like a regular lock and key, unless they have the encryption key, they will not be able to unlock (that is, decrypt) the secret encrypted message. In Figure 1-9, the outer circle’s A is over the inner circle’s number 8. That means we will be using the key 8 to encrypt our message. The Caesar cipher uses the keys from 0 to 25. Let’s use the key 8 for our example. Keep the encryption key a secret; the ciphertext can be read by anyone who knows that the message was encrypted with key 8. T H E S E C R E T P A S S W O R D ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ B P M A M K Z M B X I A A E W Z L I S R O S E B U D . ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ Q A Z W A M J C L . For each letter in our message, we will find where it is in the outer circle and replace it with the lined-up letter in the inner circle. The first letter in our message is T (the first “T” in “The secret…”), so we find the letter T in the outer circle, and then find the lined-up letter in the inner circle. This letter is B, so in our secret message we will always replace T’s with B’s. (If we were using some other encryption key besides 8, then the T’s in our plaintext would be replaced with a different letter.) The next letter in our message is H, which turns into P. The letter E turns into M. When we have encrypted the entire message, the message has transformed from “The secret password is Rosebud.” to “Bpm amkzmb xiaaewzl qa Zwamjcl.” Now you can send this message to someone (or keep it written down for yourself) and nobody will be able to read it unless you tell them the secret encryption key (the number 8). Email questions to the author: alinventwithpython.comChapter 1 – Making Paper Cryptography Tools 9 Figure 1-10. A message encrypted with the cipher wheel. Each letter on the outer wheel will always be encrypted to the same letter on the inner wheel. To save time, after you look up the first T in “The secret…” and see that it encrypts to B, you can replace every T in the message with B. This way you only need to look up a letter once. How to Decrypt with the Cipher Wheel To decrypt a ciphertext, go from the inner circle to the outer circle. Let’s say you receive this ciphertext from a friend, “Iwt ctl ephhldgs xh Hldgsuxhw.” You and everyone else won’t be able to decrypt it unless you know the key (or unless you are a clever hacker). But your friend has decided to use the key 15 for each message she sends you. Line up the letter A on the outer circle (the one with the dot below it) over the letter on the inner circle that has the number 15 (which is the letter P). The first letter in the secret message is I, so we find I on the inner circle and look at the letter next to it on the outer circle, which is T. The W in the ciphertext will decrypt to the letter H. One by one, we can decrypt each letter in the ciphertext back to the plaintext, “The new password is Swordfish.” I W T C T L E P H H L D G S ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ T H E N E W P A S S W O R D X H H L D G S U X H W . ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ I S S W O R D F I S H . If we use an incorrect key like 16 instead of the correct key 15, the decrypted message is “Sgd mdv ozrrvnqc hr Rvnqcehrg.” This plaintext doesn’t look plain at all. Unless the correct key is used, the decrypted message will never be understandable English. 10 http://inventwithpython.com/hacking A Different Cipher Tool: The St. Cyr Slide There’s another paper tool that can be used to do encryption and decryption, called the St. Cyr slide. It’s like the cipher wheel except in a straight line. Photocopy the image of the St. Cyr slide on the following page (or print it out from http://invpy.com/stcyrslide) and cut out the three strips. Tape the two alphabet strips together, with the black box A next to the white box Z on the other strip. Cut out the slits on either side of the main slide box so that the taped-together strip can feed through it. It should look like this: Figure 1-12. The completed St. Cyr Slide When the black box A is underneath the letter H (and the number 7), then to encrypt you must find where the plaintext letter is on the long strip, and replace it with the letter above it. To decrypt, find the ciphertext letter on the top row of letters and replace it with the letter on the long strip below it. The two slits on the larger box will hide any extra letters so that you only see one of each letter on the slide for any key. The benefit of the St. Cyr slide is that it might be easier to find the letters you are looking for, since they are all in a straight line and will never be upside down like they sometimes are on the cipher wheel. A virtual and printable St. Cyr slide can be found at http://invpy.com/stcyrslide. Figure 1-11. Photocopy these strips to make a St. Cyr Slide. Email questions to the author: alinventwithpython.comChapter 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 12 http://inventwithpython.com/hacking key is 26 or more, we should subtract 26 from it. So 27 – 26 is 1. The letter above the number 1 is B. So the letter O encrypts to the letter B when we are using the key 13. One by one, we can then encrypt the letters in, “Hello. How are you?” to “Uryyb. Ubj ner lbh?” So the steps to encrypt a letter are: 1. Decide on a key from 1 to 25. Keep this key secret 2. Find the plaintext letter’s number. 3. Add the key to the plaintext letter’s number. 4. If this number is larger than 26, subtract 26. 5. Find the letter for the number you’ve calculated. This is the ciphertext letter. 6. Repeat steps 2 to 5 for every letter in the plaintext message. Look at the following table to see how this is done with each letter in “Hello. How are you?” with key 13. Each column shows the steps for turning the plaintext letter on the left to the ciphertext letter on the right. Table 1-1. The steps to encrypt “Hello. How are you?” with paper and pencil. Plaintext Plaintext + Key Result Subtract Result Ciphertext Letter Number 26? Letter H 7 + 13 = 20 = 20 20 = U E 4 + 13 = 17 = 17 17 = R L 11 + 13 = 24 = 24 24 = Y L 11 + 13 = 24 = 24 24 = Y O 14 + 13 = 27 - 26 = 1 1 = B H 7 + 13 = 20 = 20 20 = U O 14 + 13 = 27 - 26 = 1 1 = B W 22 + 13 = 35 - 26 = 9 9 = J A 0 + 13 = 13 = 13 13 = N R 17 + 13 = 30 - 26 = 4 4 = E E 4 + 13 = 17 = 17 17 = R Y 24 + 13 = 37 - 26 = 11 11 = L O 14 + 13 = 27 - 26 = 1 1 = B U 20 + 13 = 33 - 26 = 7 7 = H Email questions to the author: alinventwithpython.comChapter 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 Ciphertext - Key Result Add Result Plaintext Letter Number 26? 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 = 14 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/hackingpractice1B. 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. 14 http://inventwithpython.com/hacking 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 Email questions to the author: alinventwithpython.comChapter 1 – Making Paper Cryptography Tools 15 the work for a large amount of text in less than a second But we need to learn how to instruct (that is, program) the computer to do the same steps we just did. We will have to be able to speak a language the computer can understand. Fortunately, learning a programming language isn’t nearly as hard as learning a foreign language like Japanese or Spanish. You don’t even need to know much math besides addition, subtraction, and multiplication. You just need to download some free software called Python, which we will cover in the next chapter. 16 http://inventwithpython.com/hacking INSTALLING PYTHON Topics Covered In This Chapter:  Downloading and installing Python  Downloading the Pyperclip module  How to start IDLE  Formatting used in this book  Copying and pasting text “Privacy in an open society also requires cryptography. If I say something, I want it heard only by those for whom I intend it. If the content of my speech is available to the world, I have no privacy.” Eric Hughes, “A Cypherpunk’s Manifesto”, 1993 http://invpy.com/cypherpunk The content of this chapter is very similar to the first chapter of Invent Your Own Computer Games with Python. If you have already read that book or have already installed Python, you only need to read the “Downloading pyperclip.py” section in this chapter. Email questions to the author: alinventwithpython.comChapter 2 – Downloading and Installing Python 17 Downloading and Installing Python Before we can begin programming, you’ll need to install software called the Python interpreter. (You may need to ask an adult for help here.) The interpreter is a program that understands the instructions that you’ll write in the Python language. Without the interpreter, your computer won't understand these instructions. (We'll refer to “the Python interpreter” as “Python” from now on.) Because we’ll be writing our programs in the Python language we need to download Python from the official website of the Python programming language, http://www.python.org. The installation is a little different depending on if your computer’s operating system is Windows, OS X, or a Linux distribution such as Ubuntu. You can also find videos of people installing the Python software online at http://invpy.com/installing. Important Note Be sure to install Python 3, and not Python 2. The programs in this book use Python 3, and you’ll get errors if you try to run them with Python 2. It is so important, I am adding a cartoon penguin telling you to install Python 3 so that you do not miss this message: Figure 2-1. “Be sure to install Python 3, not Python 2”, says the incongruous penguin. Windows Instructions There is a list of links on the left side of the web page at http://www.python.org. Click on the Download link to go to the download page, then look for the file called Python 3.3.0 Windows Installer (“Windows binary — does not include source”) and click on its link to download Python for Windows. (If there is a newer version than Python 3.3.0, you can download that one.) Double-click on the python-3.3.0.msi file that you’ve just downloaded to start the Python installer. (If it doesn’t start, try right-clicking the file and choosing Install.) Once the installer starts up, click the Next button and accept the choices in the installer as you go. There’s no need to make any changes. When the installer is finished, click Finish. 18 http://inventwithpython.com/hacking OS X Instructions The installation for OS X is similar. Instead of downloading the .msi file from the Python website, download the .dmg Mac Installer Disk Image file instead. The link to this file will look something like “Python 3.3.0 Mac OS X” on the “Download Python Software” web page. Ubuntu and Linux Instructions If your operating system is Ubuntu, you can install Python by opening a terminal window (click on Applications ► Accessories ► Terminal) and entering sudo apt-get install python3.3 then pressing Enter. You will need to enter the root password to install Python, so ask the person who owns the computer to type in this password. You also need to install the IDLE software. From the terminal, type in sudo apt-get install idle3. You will also need the root password to install IDLE. Downloading pyperclip.py Almost every program in this book uses a custom module I wrote called pyperclip.py. This module provides functions for letting your program copy and paste text to the clipboard. This module does not come with Python, but you can download it from: http://invpy.com/pyperclip.py This file must be in the same folder as the Python program files that you type. (A folder is also called a directory.) Otherwise you will see this error message when you try to run your program: ImportError: No module named pyperclip Starting IDLE We will be using the IDLE software to type in our programs and run them. IDLE stands for Interactive DeveLopment Environment. While Python is the software that interprets and runs your Python programs, the IDLE software is what you type your programs in. If your operating system is Windows XP, you should be able to run Python by clicking the Start button, then selecting Programs ► Python 3.3 ► IDLE (Python GUI). For Windows Vista or Windows 7, click the Windows button in the lower left corner, type “IDLE” and select “IDLE (Python GUI)”. If your operating system is Max OS X, start IDLE by opening the Finder window and clicking on Applications, then click Python 3.3, then click the IDLE icon. Email questions to the author: alinventwithpython.comChapter 2 – Downloading and Installing Python 19 If your operating system is Ubuntu or Linux, start IDLE by clicking Applications ► Accessories ► Terminal and then type idle3. You may also be able to click on Applications at the top of the screen, and then select Programming and then IDLE 3. Figure 2-2. IDLE running on Windows (left), OS X (center), and Ubuntu Linux (right). The window that appears will be mostly blank except for text that looks something like this: Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) MSC v.1600 64 bit (AMD64) on win32 Type "copyright", "credits" or "license()" for more information. The window that appears when you first run IDLE is called the interactive shell. A shell is a program that lets you type instructions into the computer. The Python shell lets you type Python instructions in and then sends these instructions to the Python interpreter software to run. We can type Python instructions into the shell and, because the shell is interactive, the computer will read our instructions and perform them immediately. The Featured Programs “Hacking Secret Ciphers with Python” is different from other programming books because it focuses on the source code for complete programs. Instead of teaching you programming concepts and leaving it up to you to figure out how to make your own programs, this book shows you complete programs and explains how they work. As you read through this book, type the source code from this book into IDLE yourself. But you can also download the source code files from this book’s website. Go to the web site http://invpy.com/hackingsource and follow the instructions to download the source code files. In general, you should read this book from front to back. The programming concepts build on the previous chapters. However, Python is such a readable language that after the first few chapters you can probably piece together what the code does. If you jump ahead and feel lost, try 20 http://inventwithpython.com/hacking going back to the previous chapters. Or email your programming questions to the author at alinventwithpython.com. Line Numbers and Spaces When entering the source code yourself, do not type the line numbers that appear at the beginning of each line. For example, if you see this in the book: 1. number = random.randint(1, 20) 2. spam = 42 3. print('Hello world') …then you do not need to type the “1.” on the left side, or the space that immediately follows it. Just type it like this: number = random.randint(1, 20) spam = 42 print('Hello world') Those numbers are only used so that this book can refer to specific lines in the code. They are not a part of the actual program. Aside from the line numbers, be sure to enter the code exactly as it appears. This includes the letter casing. In Python, HELLO and hello and Hello could refer to three different things. Notice that some of the lines don’t begin at the leftmost edge of the page, but are indented by four or eight spaces. Be sure to put in the correct number of spaces at the start of each line. (Since each character in IDLE is the same width, you can count the number of spaces by counting the number of characters above or below the line you’re looking at.) For example, you can see that the second line is indented by four spaces because the four characters (“whil”) on the line above are over the indented space. The third line is indented by another four spaces (the four characters “if n” are above the third line’s indented space): while spam 10: if number == 42: print('Hello') Text Wrapping in This Book Some lines of code are too long to fit on one line on the page, and the text of the code will wrap around to the next line. When you type these lines into the file editor, enter the code all on one line without pressing Enter. Email questions to the author: alinventwithpython.comChapter 2 – Downloading and Installing Python 21 You can tell when a new line starts by looking at the line numbers on the left side of the code. The example below has only two lines of code, even though the first line is too long to fit on the page: 1. print('This is the first line xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx’) 2. print('This is the second line') Tracing the Program Online Tracing a program means to step through the code one line at a time, in the same way that a computer would execute it. You can visit http://invpy.com/hackingtraces to see a trace through of each program in this book. The traces web page has notes and helpful reminders at each step of the trace to explain what the program is doing, so it can help you better understand why these programs work the way they do. Checking Your Typed Code with the Online Diff Tool Although it is very helpful to learn Python by typing out the source code for these programs, you may accidentally make typos that cause your programs to crash. It may not be obvious where the typo is. You can copy and paste the text of your typed source code to the online diff tool on the book’s website. The diff tool will show any differences between the source code in the book and the source code you’ve typed. This is an easy way of finding any typos in your programs. The online diff tool is at this web page: http://invpy.com/hackingdiff. A video tutorial of how to use the diff tool is available from this book’s website at http://invpy.com/hackingvideos. Copying and Pasting Text Copying and pasting text is a very useful computer skill, especially for this book because many of the texts that will be encrypted or decrypted are quite long. Instead of typing them out, you can look at electronic versions of the text on this book’s website and copy the text from your browser and paste it into IDLE. To copy and paste text, you first need to drag the mouse over the text you want to copy. This will highlight the text. Then you can either click on the Edit ► Copy menu item, or on Windows press Ctrl-C. (That’s press and hold the Ctrl button, then press C once, then let go of the Ctrl button.) On Macs, the keyboard shortcut is Command-C (the ⌘ button). This will copy the highlighted text to the computer’s memory, or clipboard. 22 http://inventwithpython.com/hacking To paste the text that is on the clipboard, move the cursor to the place you want the text to be inserted. Then either click on the Edit ► Paste menu item or press Ctrl-V or Command-V. Pasting will have the same effect as if you typed out all the characters that were copied to the clipboard. Copying and pasting can save you a lot of typing time, and unlike typing it will never make a mistake in reproducing the text. You should note that every time you copy text to the clipboard, the previous text that was on the clipboard is forgotten. There is a tutorial on copying and pasting at this book’s website at http://invpy.com/copypaste. More Info Links There is a lot that you can learn about programming and cryptography, but you don’t need to learn all of it now. There are several times where you might like to learn these additional details and explanations, but if I included them in this book then it would add many more pages. Publication of this larger book would place so much combustible paper into a single space that the book would be a fire hazard. Instead, I have included “more info” links in this book that you can follow to this book’s website. You do not have to read this additional information to understand anything in this book, but it will help you learn. These links begin with http://invpy.com (which is the shortened URL for the “Invent with Python” book website.) Even though this book is not a dangerous fire hazard, please do not set it on fire anyway. Programming and Cryptography Programming and cryptography are two separate skills, but learning both is useful because a computer can do cryptography much faster than a human can. For example, here is the entire text of William Shakespeare’s “Romeo and Juliet” encrypted with a simple substitution cipher: WUMIU FOT LZNCIB JWUNURZI Dguwzh Bku guzhigunth, qubg fncei co tcrocbx, Co afcw Piwuof, kgiwi ki nfx uzw hdioi, Awum fodciob rwztri qwife bu oik mzbcox, Kgiwi dcpcn qnuut mfeih dcpcn gfoth zodnifo. Awum auwbg bgi afbfn nucoh ua bgihi bku auih F jfcw ua hbfw-dwuhh't nupiwh bfei bgicw ncai; Kguni mchftpiobzwit jcbiuzh upiwbgwukh Tu kcbg bgicw tifbg qzwx bgicw jfwiobh' hbwcai. Bgi aifwazn jfhhfri ua bgicw tifbg-mfwe't nupi, Fot bgi duobcozfodi ua bgicw jfwiobh' wfri, Kgcdg, qzb bgicw dgcntwio'h iot, ouzrgb duznt wimupi, Ch ouk bgi bku guzwh' bwfaacd ua uzw hbfri; Bgi kgcdg ca xuz kcbg jfbciob ifwh fbbiot, Kgfb giwi hgfnn mchh, uzw bucn hgfnn hbwcpi bu miot. WUMIU FOT LZNCIB FDB C HDIOI C Piwuof. F jzqncd jnfdi. Iobiw HFMJHUO fot RWIRUWX, ua bgi guzhi ua Dfjznib, fwmit kcbg hkuwth fot qzdeniwh HFMJHUO Rwiruwx, u' mx kuwt, ki'nn oub dfwwx dufnh. RWIRUWX Ou, auw bgio ki hguznt qi dunnciwh. HFMJHUO C mifo, fo ki qi co dguniw, ki'nn twfk. RWIRUWX Fx, kgcni xuz ncpi, twfk xuzw oide uzb u' bgi dunnfw. HFMJHUO C hbwcei yzcdenx, qicor mupit. RWIRUWX Qzb bguz fwb oub yzcdenx mupit bu hbwcei. HFMJHUO F tur ua bgi guzhi ua Muobfrzi mupih mi. RWIRUWX Bu mupi ch bu hbcw; fot bu qi pfncfob ch bu hbfot: bgiwiauwi, ca bguz fwb mupit, bguz wzoo'hb fkfx. HFMJHUO F tur ua bgfb guzhi hgfnn mupi mi bu hbfot: C kcnn bfei bgi kfnn ua fox mfo uw mfct ua Muobfrzi'h. RWIRUWX Bgfb hgukh bgii f kife hnfpi; auw bgi kifeihb ruih bu bgi kfnn. HFMJHUO Bwzi; fot bgiwiauwi kumio, qicor bgi kifeiw pihhinh, fwi ipiw bgwzhb bu bgi kfnn: bgiwiauwi C kcnn jzhg Muobfrzi'h mio awum bgi kfnn, fot bgwzhb gch mfcth bu bgi kfnn. RWIRUWX Bgi yzfwwin ch qibkiio uzw mfhbiwh fot zh bgicw mio. HFMJHUO 'Bch fnn uoi, C kcnn hguk mxhina f bxwfob: kgio C gfpi auzrgb kcbg bgi mio, C kcnn qi dwzin kcbg bgi mfcth, fot dzb uaa bgicw gifth. RWIRUWX Bgi gifth ua bgi mfcth? HFMJHUO Fx, bgi gifth ua bgi mfcth, uw bgicw mfctiogifth; bfei cb co kgfb hiohi bguz kcnb. RWIRUWX Bgix mzhb bfei cb co hiohi bgfb aiin cb. HFMJHUO Mi bgix hgfnn aiin kgcni C fm fqni bu hbfot: fot 'bch eouko C fm f jwibbx jcidi ua anihg. RWIRUWX 'Bch kinn bguz fwb oub achg; ca bguz gfthb, bguz gfthb qiio juuw Lugo. Twfk bgx buun giwi dumih bku ua bgi guzhi ua bgi Muobfrzih. HFMJHUO Mx ofeit kifjuo ch uzb: yzfwwin, C kcnn qfde bgii. RWIRUWX Guk bzwo bgx qfde fot wzo? HFMJHUO Aifw mi oub. RWIRUWX Ou, mfwwx; C aifw bgii HFMJHUO Nib zh bfei bgi nfk ua uzw hctih; nib bgim qirco. RWIRUWX C kcnn awuko fh C jfhh qx, fot nib bgim bfei cb fh bgix nchb. HFMJHUO Ofx, fh bgix tfwi. C kcnn qcbi mx bgzmq fb bgim; kgcdg ch f tchrwfdi bu bgim, ca bgix qifw cb. Iobiw FQWFGFM fot QFNBGFHFW FQWFGFM Tu xuz qcbi xuzw bgzmq fb zh, hcw? HFMJHUO C tu qcbi mx bgzmq, hcw. FQWFGFM Tu xuz qcbi xuzw bgzmq fb zh, hcw? HFMJHUO Fhcti bu RWIRUWX Ch bgi nfk ua uzw hcti, ca C hfx fx? RWIRUWX Ou. HFMJHUO Ou, hcw, C tu oub qcbi mx bgzmq fb xuz, hcw, qzb C qcbi mx bgzmq, hcw. RWIRUWX Tu xuz yzfwwin, hcw? FQWFGFM Yzfwwin hcw ou, hcw. HFMJHUO Ca xuz tu, hcw, C fm auw xuz: C hiwpi fh ruut f mfo fh xuz. FQWFGFM Ou qibbiw. HFMJHUO Kinn, hcw. RWIRUWX Hfx 'qibbiw:' giwi dumih uoi ua mx mfhbiw'h ecohmio. HFMJHUO Xih, qibbiw, hcw. FQWFGFM Xuz nci. HFMJHUO Twfk, ca xuz qi mio. Rwiruwx, wimimqiw bgx hkfhgcor qnuk. Bgix acrgb Iobiw QIOPUNCU QIOPUNCU Jfwb, auunh Jzb zj xuzw hkuwth; xuz eouk oub kgfb xuz tu. Qifbh tuko bgicw hkuwth Iobiw BXQFNB BXQFNB Kgfb, fwb bguz twfko fmuor bgihi gifwbnihh gcoth? Bzwo bgii, Qiopuncu, nuue zjuo bgx tifbg. QIOPUNCU C tu qzb eiij bgi jifdi: jzb zj bgx hkuwt, Uw mfofri cb bu jfwb bgihi mio kcbg mi. BXQFNB Kgfb, twfko, fot bfne ua jifdi C gfbi bgi kuwt, Fh C gfbi ginn, fnn Muobfrzih, fot bgii: Gfpi fb bgii, dukfwt Bgix acrgb Iobiw, hipiwfn ua qubg guzhih, kgu luco bgi awfx; bgio iobiw Dcbcvioh, kcbg dnzqh Acwhb Dcbcvio Dnzqh, qcnnh, fot jfwbchfoh hbwcei qifb bgim tuko Tuko kcbg bgi Dfjznibh tuko kcbg bgi Muobfrzih Iobiw DFJZNIB co gch ruko, fot NFTX DFJZNIB DFJZNIB Kgfb ouchi ch bgch? Rcpi mi mx nuor hkuwt, gu NFTX DFJZNIB F dwzbdg, f dwzbdg kgx dfnn xuz auw f hkuwt? DFJZNIB Mx hkuwt, C hfx Unt Muobfrzi ch dumi, Fot anuzwchgih gch qnfti co hjcbi ua mi. Iobiw MUOBFRZI fot NFTX MUOBFRZI MUOBFRZI Bguz pcnnfco Dfjznib,Gunt mi oub, nib mi ru. NFTX MUOBFRZI Bguz hgfnb oub hbcw f auub bu hiie f aui. Iobiw JWCODI, kcbg Fbbiotfobh JWCODI Wiqinncuzh hzqlidbh, ioimcih bu jifdi, Jwuafoiwh ua bgch oicrgquzw-hbfcoit hbiin, Kcnn bgix oub gifw? Kgfb, gu xuz mio, xuz qifhbh, Bgfb yziodg bgi acwi ua xuzw jiwocdcuzh wfri Kcbg jzwjni auzobfcoh chhzcor awum xuzw picoh, Uo jfco ua buwbzwi, awum bguhi qnuutx gfoth Bgwuk xuzw mchbimjiw't kifjuoh bu bgi rwuzot, Fot gifw bgi hiobiodi ua xuzw mupit jwcodi. Bgwii dcpcn qwfknh, qwit ua fo fcwx kuwt, Qx bgii, unt Dfjznib, fot Muobfrzi, Gfpi bgwcdi tchbzwq't bgi yzcib ua uzw hbwiibh, Fot mfti Piwuof'h fodciob dcbcvioh Dfhb qx bgicw rwfpi qihiimcor uwofmiobh, Bu kcint unt jfwbchfoh, co gfoth fh unt, Dfoeiw't kcbg jifdi, bu jfwb xuzw dfoeiw't gfbi: Ca ipiw xuz tchbzwq uzw hbwiibh frfco, Xuzw ncpih hgfnn jfx bgi auwaicb ua bgi jifdi. Auw bgch bcmi, fnn bgi wihb tijfwb fkfx: Xuz Dfjznib; hgfnn ru fnuor kcbg mi: Fot, Muobfrzi, dumi xuz bgch fabiwouuo, Bu eouk uzw azwbgiw jnifhzwi co bgch dfhi, Bu unt Awii-buko, uzw dummuo lztrmiob-jnfdi. Uodi muwi, uo jfco ua tifbg, fnn mio tijfwb. Isizob fnn qzb MUOBFRZI, NFTX MUOBFRZI, fot QIOPUNCU MUOBFRZI Kgu hib bgch fodciob yzfwwin oik fqwufdg? Hjife, oijgik, kiwi xuz qx kgio cb qirfo? QIOPUNCU Giwi kiwi bgi hiwpfobh ua xuzw ftpiwhfwx, Fot xuzwh, dnuhi acrgbcor iwi C tct fjjwufdg: C twik bu jfwb bgim: co bgi cohbfob dfmi Bgi aciwx Bxqfnb, kcbg gch hkuwt jwijfwit, Kgcdg, fh gi qwifbgit tiacfodi bu mx ifwh, Gi hkzor fquzb gch gift fot dzb bgi kcoth, Kgu oubgcor gzwb kcbgfn gchh't gcm co hduwo: Kgcni ki kiwi cobiwdgforcor bgwzhbh fot qnukh, Dfmi muwi fot muwi fot auzrgb uo jfwb fot jfwb, Bcnn bgi jwcodi dfmi, kgu jfwbit icbgiw jfwb. NFTX MUOBFRZI U, kgiwi ch Wumiu? hfk xuz gcm bu-tfx? Wcrgb rnft C fm gi kfh oub fb bgch awfx. QIOPUNCU Mftfm, fo guzw qiauwi bgi kuwhgcjj't hzo Jiiw't auwbg bgi runtio kcotuk ua bgi ifhb, F bwuzqnit mcot twfpi mi bu kfne fqwuft; Kgiwi, zotiwoifbg bgi rwupi ua hxdfmuwi Bgfb kihbkfwt wuubibg awum bgi dcbx'h hcti, Hu ifwnx kfnecor tct C hii xuzw huo: Bukfwth gcm C mfti, qzb gi kfh kfwi ua mi Fot hbuni cobu bgi dupiwb ua bgi kuut: C, mifhzwcor gch faaidbcuoh qx mx uko, Bgfb muhb fwi qzhcit kgio bgix'wi muhb fnuoi, Jzwhzit mx gzmuzw oub jzwhzcor gch, Fot rnftnx hgzoo't kgu rnftnx anit awum mi. MUOBFRZI Mfox f muwocor gfbg gi bgiwi qiio hiio, Kcbg bifwh fzrmiobcor bgi awihg muwocor tik. Fttcor bu dnuzth muwi dnuzth kcbg gch tiij hcrgh; Qzb fnn hu huuo fh bgi fnn-dgiiwcor hzo Hguznt co bgi azwbgihb ifhb qirco bu twfk Bgi hgftx dzwbfcoh awum Fzwuwf'h qit, Fkfx awum bgi ncrgb hbifnh gumi mx gifpx huo, Fot jwcpfbi co gch dgfmqiw jioh gcmhina, Hgzbh zj gch kcotukh, nudeh afw tfxncrgb uzb Fot mfeih gcmhina fo fwbcacdcfn ocrgb: Qnfde fot juwbiobuzh mzhb bgch gzmuzw jwupi, Zonihh ruut duzohin mfx bgi dfzhi wimupi. QIOPUNCU Mx ouqni zodni, tu xuz eouk bgi dfzhi? MUOBFRZI C oicbgiw eouk cb ouw dfo nifwo ua gcm. QIOPUNCU Gfpi xuz cmjuwbzoit gcm qx fox mifoh? MUOBFRZI Qubg qx mxhina fot mfox ubgiw awcioth: Qzb gi, gch uko faaidbcuoh' duzohinnuw, Ch bu gcmhinaC kcnn oub hfx guk bwzi Qzb bu gcmhina hu hidwib fot hu dnuhi, Hu afw awum huzotcor fot tchdupiwx, Fh ch bgi qzt qcb kcbg fo iopcuzh kuwm, Iwi gi dfo hjwift gch hkiib nifpih bu bgi fcw, Uw titcdfbi gch qifzbx bu bgi hzo. Duznt ki qzb nifwo awum kgiodi gch huwwukh rwuk. Ki kuznt fh kcnncornx rcpi dzwi fh eouk. Iobiw WUMIU QIOPUNCU Hii, kgiwi gi dumih: hu jnifhi xuz, hbij fhcti; C'nn eouk gch rwcipfodi, uw qi mzdg tiocit. MUOBFRZI C kuznt bguz kiwb hu gfjjx qx bgx hbfx, Bu gifw bwzi hgwcab. Dumi, mftfm, nib'h fkfx. Isizob MUOBFRZI fot NFTX MUOBFRZI QIOPUNCU Ruut-muwwuk, duzhco. WUMIU Ch bgi tfx hu xuzor? QIOPUNCU Qzb oik hbwzde ocoi. WUMIU Fx mi hft guzwh hiim nuor. Kfh bgfb mx afbgiw bgfb kiob giodi hu afhb? QIOPUNCU Cb kfh. Kgfb hftoihh niorbgioh Wumiu'h guzwh? WUMIU Oub gfpcor bgfb, kgcdg, gfpcor, mfeih bgim hguwb. QIOPUNCU Co nupi? WUMIU Uzb QIOPUNCU Ua nupi? WUMIU Uzb ua giw afpuzw, kgiwi C fm co nupi. QIOPUNCU Fnfh, bgfb nupi, hu riobni co gch pcik, Hguznt qi hu bxwfoouzh fot wuzrg co jwuua WUMIU Fnfh, bgfb nupi, kguhi pcik ch mzaanit hbcnn, Hguznt, kcbguzb ixih, hii jfbgkfxh bu gch kcnn Kgiwi hgfnn ki tcoi? U mi Kgfb awfx kfh giwi? Xib binn mi oub, auw C gfpi gifwt cb fnn. Giwi'h mzdg bu tu kcbg gfbi, qzb muwi kcbg nupi. Kgx, bgio, U qwfkncor nupi U nupcor gfbi U fox bgcor, ua oubgcor acwhb dwifbi U gifpx ncrgboihh hiwcuzh pfocbx Mch-hgfjio dgfuh ua kinn-hiimcor auwmh Aifbgiw ua nift, qwcrgb hmuei, dunt acwi, hcde gifnbg Hbcnn-kfecor hniij, bgfb ch oub kgfb cb ch Bgch nupi aiin C, bgfb aiin ou nupi co bgch. Tuhb bguz oub nfzrg? QIOPUNCU Ou, duv, C wfbgiw kiij. WUMIU Ruut gifwb, fb kgfb? QIOPUNCU Fb bgx ruut gifwb'h ujjwihhcuo. WUMIU Kgx, hzdg ch nupi'h bwfohrwihhcuo. Rwciah ua mcoi uko nci gifpx co mx qwifhb, Kgcdg bguz kcnb jwujfrfbi, bu gfpi cb jwihb Kcbg muwi ua bgcoi: bgch nupi bgfb bguz gfhb hguko Tubg ftt muwi rwcia bu buu mzdg ua mcoi uko. Nupi ch f hmuei wfchit kcbg bgi azmi ua hcrgh; Qicor jzwrit, f acwi hjfwencor co nupiwh' ixih; Qicor pis't f hif ouzwchg't kcbg nupiwh' bifwh: Kgfb ch cb inhi? f mftoihh muhb tchdwiib, F dguecor rfnn fot f jwihiwpcor hkiib. Afwikinn, mx duv. QIOPUNCU Huab C kcnn ru fnuor; Fo ca xuz nifpi mi hu, xuz tu mi kwuor. WUMIU Bzb, C gfpi nuhb mxhina; C fm oub giwi; Bgch ch oub Wumiu, gi'h humi ubgiw kgiwi. QIOPUNCU Binn mi co hftoihh, kgu ch bgfb xuz nupi. WUMIU Kgfb, hgfnn C rwufo fot binn bgii? QIOPUNCU Rwufo kgx, ou. Qzb hftnx binn mi kgu. WUMIU Qct f hcde mfo co hftoihh mfei gch kcnn: Fg, kuwt cnn zwrit bu uoi bgfb ch hu cnn Co hftoihh, duzhco, C tu nupi f kumfo. QIOPUNCU C fcm't hu oifw, kgio C hzjjuhit xuz nupit. WUMIU F wcrgb ruut mfwe-mfo Fot hgi'h afcw C nupi. QIOPUNCU F wcrgb afcw mfwe, afcw duv, ch huuoihb gcb. WUMIU Kinn, co bgfb gcb xuz mchh: hgi'nn oub qi gcb Kcbg Dzjct'h fwwuk; hgi gfbg Tcfo'h kcb; Fot, co hbwuor jwuua ua dgfhbcbx kinn fwm't, Awum nupi'h kife dgcntchg quk hgi ncpih zogfwm't. Hgi kcnn oub hbfx bgi hciri ua nupcor biwmh, Ouw qcti bgi ioduzobiw ua fhhfcncor ixih, Ouw uji giw nfj bu hfcob-hitzdcor runt: U, hgi ch wcdg co qifzbx, uonx juuw, Bgfb kgio hgi tcih kcbg qifzbx tcih giw hbuwi. QIOPUNCU Bgio hgi gfbg hkuwo bgfb hgi kcnn hbcnn ncpi dgfhbi? WUMIU Hgi gfbg, fot co bgfb hjfwcor mfeih gzri kfhbi, Auw qifzbx hbfwpit kcbg giw hipiwcbx Dzbh qifzbx uaa awum fnn juhbiwcbx. Hgi ch buu afcw, buu kchi, kchinx buu afcw, Bu miwcb qnchh qx mfecor mi tihjfcw: Hgi gfbg auwhkuwo bu nupi, fot co bgfb puk Tu C ncpi tift bgfb ncpi bu binn cb ouk. QIOPUNCU Qi wznit qx mi, auwrib bu bgcoe ua giw. WUMIU U, bifdg mi guk C hguznt auwrib bu bgcoe. QIOPUNCU Qx rcpcor ncqiwbx zobu bgcoi ixih; Isfmcoi ubgiw qifzbcih. WUMIU 'Bch bgi kfx Bu dfnn giwh isyzchcbi, co yzihbcuo muwi: Bgihi gfjjx mfheh bgfb echh afcw nftcih' qwukh Qicor qnfde jzb zh co mcot bgix gcti bgi afcw; Gi bgfb ch hbwzdeio qncot dfooub auwrib Bgi jwidcuzh bwifhzwi ua gch ixihcrgb nuhb: Hguk mi f mchbwihh bgfb ch jfhhcor afcw, Kgfb tubg giw qifzbx hiwpi, qzb fh f oubi Kgiwi C mfx wift kgu jfhh't bgfb jfhhcor afcw? Afwikinn: bguz dfohb oub bifdg mi bu auwrib. QIOPUNCU C'nn jfx bgfb tudbwcoi, uw inhi tci co tiqb. Isizob WUMIU FOT LZNCIB FDB C HDIOI CC F hbwiib. Iobiw DFJZNIB, JFWCH, fot Hiwpfob DFJZNIB Qzb Muobfrzi ch quzot fh kinn fh C, Co jiofnbx fncei; fot 'bch oub gfwt, C bgcoe, Auw mio hu unt fh ki bu eiij bgi jifdi. JFWCH Ua guouzwfqni wideuocor fwi xuz qubg; Fot jcbx 'bch xuz ncpit fb utth hu nuor. Qzb ouk, mx nuwt, kgfb hfx xuz bu mx hzcb? DFJZNIB Qzb hfxcor u'iw kgfb C gfpi hfct qiauwi: Mx dgcnt ch xib f hbwforiw co bgi kuwnt; Hgi gfbg oub hiio bgi dgfori ua auzwbiio xifwh, Nib bku muwi hzmmiwh kcbgiw co bgicw jwcti, Iwi ki mfx bgcoe giw wcji bu qi f qwcti. JFWCH Xuzoriw bgfo hgi fwi gfjjx mubgiwh mfti. DFJZNIB Fot buu huuo mfww't fwi bguhi hu ifwnx mfti. Bgi ifwbg gfbg hkfnnuk't fnn mx gujih qzb hgi, Hgi ch bgi gujiazn nftx ua mx ifwbg: Qzb kuu giw, riobni Jfwch, rib giw gifwb, Mx kcnn bu giw duohiob ch qzb f jfwb; Fo hgi frwii, kcbgco giw hduji ua dgucdi Ncih mx duohiob fot afcw fdduwtcor pucdi. Bgch ocrgb C gunt fo unt fddzhbum't aifhb, Kgiwibu C gfpi copcbit mfox f rzihb, Hzdg fh C nupi; fot xuz, fmuor bgi hbuwi, Uoi muwi, muhb kindumi, mfeih mx ozmqiw muwi. Fb mx juuw guzhi nuue bu qigunt bgch ocrgb Ifwbg-bwiftcor hbfwh bgfb mfei tfwe gifpio ncrgb: Hzdg dumauwb fh tu nzhbx xuzor mio aiin Kgio kinn-fjjfwinn't Fjwcn uo bgi giin Ua ncmjcor kcobiw bwifth, ipio hzdg tincrgb Fmuor awihg aimfni qzth hgfnn xuz bgch ocrgb Cogiwcb fb mx guzhi; gifw fnn, fnn hii, Fot ncei giw muhb kguhi miwcb muhb hgfnn qi: Kgcdg uo muwi pcik, ua mfox mcoi qicor uoi Mfx hbfot co ozmqiw, bguzrg co wideuocor ouoi, Dumi, ru kcbg mi. Bu Hiwpfob, rcpcor f jfjiw Ru, hcwwfg, bwztri fquzb Bgwuzrg afcw Piwuof; acot bguhi jiwhuoh uzb Kguhi ofmih fwi kwcbbio bgiwi, fot bu bgim hfx, Mx guzhi fot kindumi uo bgicw jnifhzwi hbfx. Isizob DFJZNIB fot JFWCH Hiwpfob Acot bgim uzb kguhi ofmih fwi kwcbbio giwi Cb ch kwcbbio, bgfb bgi hguimfeiw hguznt mittni kcbg gch xfwt, fot bgi bfcnuw kcbg gch nfhb, bgi achgiw kcbg gch jiodcn, fot bgi jfcobiw kcbg gch oibh; qzb C fm hiob bu acot bguhi jiwhuoh kguhi ofmih fwi giwi kwcb, fot dfo oipiw acot kgfb ofmih bgi kwcbcor jiwhuo gfbg giwi kwcb. C mzhb bu bgi nifwoit.Co ruut bcmi. Iobiw QIOPUNCU fot WUMIU QIOPUNCU Bzb, mfo, uoi acwi qzwoh uzb foubgiw'h qzwocor, Uoi jfco ch nihhio't qx foubgiw'h forzchg; Bzwo rcttx, fot qi gunj qx qfdekfwt bzwocor; Uoi tihjiwfbi rwcia dzwih kcbg foubgiw'h nforzchg: Bfei bguz humi oik coaidbcuo bu bgx ixi, Fot bgi wfoe juchuo ua bgi unt kcnn tci. WUMIU Xuzw jnfcobfco-nifa ch isdinniob auw bgfb. QIOPUNCU Auw kgfb, C jwfx bgii? WUMIU Auw xuzw qwueio hgco. QIOPUNCU Kgx, Wumiu, fwb bguz mft? WUMIU Oub mft, qzb quzot muwi bgfo f mft-mfo ch; Hgzb zj co jwchuo, eijb kcbguzb mx auut, Kgcjj't fot buwmiobit fotRut-tio, ruut ainnuk. Hiwpfob Rut rc' rut-tio. C jwfx, hcw, dfo xuz wift? WUMIU Fx, mcoi uko auwbzoi co mx mchiwx. Hiwpfob Jiwgfjh xuz gfpi nifwoit cb kcbguzb quue: qzb, C jwfx, dfo xuz wift fox bgcor xuz hii? WUMIU Fx, ca C eouk bgi nibbiwh fot bgi nforzfri. Hiwpfob Xi hfx guoihbnx: wihb xuz miwwx WUMIU Hbfx, ainnuk; C dfo wift. Wifth 'Hcrocuw Mfwbcou fot gch kcai fot tfzrgbiwh; Duzobx Fohinmi fot gch qifzbiuzh hchbiwh; bgi nftx kctuk ua Pcbwfpcu; Hcrocuw Jnfdiobcu fot gch nupinx ocidih; Miwdzbcu fot gch qwubgiw Pfniobcoi; mcoi zodni Dfjznib, gch kcai fot tfzrgbiwh; mx afcw ocidi Wuhfncoi; Ncpcf; Hcrocuw Pfniobcu fot gch duzhco Bxqfnb, Nzdcu fot bgi ncpinx Giniof.' F afcw fhhimqnx: kgcbgiw hguznt bgix dumi? Hiwpfob Zj. Email questions to the author: alinventwithpython.com