GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing inventwithpython.com — ROT 13 Cipher BUY THIS BOOK: No Starch Press (free ebook) | Amazon | Barnes and Noble | Powell's | Bookshop.org | Goodreads | Kobo | Thriftbooks
SUPPORT THE AUTHOR: Patreon or Donate Directly
Prev: Rock Paper Scissors (Always-Win Version) | Next: Rotating Cube
The ROT13 cipher, one of the simplest encryption algorithms, stands for “rotate 13 spaces.” The cypher represents the letters A to Z as the numbers 0 to 25 in such a way that the encrypted letter is 13 spaces from the plaintext letter: A becomes N, B becomes O, and so on. The encryption process is identical to the decryption process, making it trivial to program. However, the encryption is also trivial to break. Because of this, you’ll most often find ROT13 used to conceal non-sensitive information, such as spoilers or trivia answers, so it’s not read unintentionally. More information about the ROT13 cipher can be found at https://en.wikipedia.org/wiki/ROT13. If you’d like to learn about ciphers and code breaking more generally, you can read my book Cracking Codes with Python (No Starch Press, 2018; https://nostarch.com/crackingcodes/). The Program in ActionWhen you run rot13cipher.py, the output will look like this:
How It WorksROT13 shares a lot of code with Project 6, “Caesar Cipher,” although it’s much simpler because it always uses the key 13. Since the same code performs both the encryption and decryption (lines 27 to 39), there’s no need to ask the player which mode they want to use. One difference is that this program maintains the casing of the original message instead of automatically converting the message to uppercase. For example, “Hello” encrypts to “Uryyb,” whereas “HELLO” encrypts to “URYYB.”
Exploring the ProgramTry to find the answers to the following questions. Experiment with some modifications to the code and rerun the program to see what effect the changes have.
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |