Geek Culture
Published in

Geek Culture

Deciphering Taylor Swift and the Krabby Patty Secret Formula: The Basics of Cryptography

Gems in STEM: Quick Intro to Cryptography

Before we get started, let me tell you why I’ve decided that it is my duty to help equip the masses with the basics of cryptography by writing this column. My sister is a major Swiftie and literally every week she claims that Taylor Swift will be releasing something huge! (Every week she is wrong.) Apparently, the legendary T. Swift is notorious for the hidden messages within her beautiful lyrics, stunning music videos, and general social media presence, and I unashamedly admit that I have recently gotten caught in her web of intrigue.

Taylor Swift at the Brit Awards 2021

So far, the messages (at least the ones I know of) haven’t been extravagantly encrypted, but recently they have gotten rather tricky. So, we must prepare to decipher more complex clues in the future!

Thus began my journey into learning a couple things about encryption, or cryptography. If you haven’t already figured it out, cryptography is the science of encrypting information and it is everywhere–including the very website you’re on right now (see that little lock at the top and/or the https://?That means your computer is currently using public key encryption to exchange data securely with the website! It’s kinda cute <3).

Secrets have been alive for as long as people have (oops). Naturally, we need to find a way to keep these secrets, or bad things™ happen. To figure out how we can do this, first suppose we have two people. Now, it’s some sort of cryptography tradition to have these two people be named Alice and Bob, but I’m tired of their secrets and I want them to live honest lives. So, instead we’ll be eavesdropping on Patrick and SpongeBob, just because I think that would be interesting and I apparently haven’t matured since kindergarten (but honestly SpongeBob is for forever).

Let’s say SpongeBob wants to pass the message: “This is the Krabby Patty Secret Formula: <redacted for security reasons>” to Patrick. Obviously, this formula cannot be leaked and if someone (i.e. Plankton) intercepts this message, Mr. Krabs will collapse. Luckily, SpongeBob has heard of a Roman general named Julius Caesar who encrypted military commands using an alphabet shift cipher–now known as the Caesar Cipher–and decides to use this to encrypt his message.

Source: SpongeBob Squarepants

But first, some quick definitions! The ordinary information or message we want to pass along is called the plaintext. For simplicity’s sake, let’s just consider “This is the Krabby Patty Secret Formula” to be SpongeBob’s plaintext. Now, we want to convert this, or encrypt it, into an unintelligible form called the ciphertext.

So how does the Caesar Cipher work? Well, there’s a reason it’s called a shift cipher–all it does is shift each letter by a fixed number up or down the alphabet.

Here’s an example of what it looks like for a shift of 3:

Shift of 3

As you can see, A -> D, B -> E, C -> F, … , X -> A, Y -> B, Z -> C, so it loops around when you reach the end of the alphabet.

Let’s now encrypt our message! Taylor’s favorite number is 13, so naturally we’ll apply the cipher for a shift of 13.

Then, T -> G, H -> U, I -> V, S -> and so on (I’ll spare you the details). Thus, our plaintext: “This is the Krabby Patty Secret Formula” becomes the ciphertext: “Guvf vf gur Xenool Cnggl Frperg Sbezhyn.” (Yes, I did use an online encoder, sue me.)

Voila! Formula encrypted! Secret kept! Mission accomplished!

…Or is it? There’s an obvious problem with this — Plankton can easily crack the code by just trying every possible shift of 1–25 (a shift of 26 would just be the same message). Even if he was too lazy to do it, his wife Karen is literally a waterproof supercomputer that can do it for him, and the message would be decrypted in (way) less than a second.

Okay, SpongeBob is not afraid of a challenge (for proof, see driver’s license episode). So, let’s make it harder! Instead of a constant shift, let’s shift each letter by a different amount. This method of encryption is called the Vigenère cipher. Note that this combination of shifts is the key, as Patrick (the star receiving the message) needs to know said key in order to decrypt the ciphertext.

There’s a couple ways this key can be expressed. The most common way is by a letter-message, something like “folklore.” To encrypt our message, we match up each letter of the plaintext with the key and take the intersection in this table, called the Vigenère square or tabula recta.

Vigenère square

As always, here’s a quick example to make sense of the cipher!

Example of Vigenère cipher

Now, let’s encrypt our message once again:

Plaintext: THIS IS THE KRABBY PATTY SECRET FORMULA

Keyword: FOLK LO REF OLKLOR EFOLK LOREFO LKLOREF

Ciphertext: YVTC TG KLJ YCKMPP TFHEI DSTVJH QYCALPF

(If you want, you can double check my work as a fun exercise!)

Why is the Vigenère cipher better than the Caesar cipher? Well, for one, guessing the key is clearly much harder! Plankton definitely would not be able to crack the code by hand. However, Karen unfortunately could crack this encryption in just a couple seconds. Moreover, you could potentially do a pattern analysis on the ciphertext and figure out the key based on the letters that are the most common, like the letter e.

So, today, how do we encrypt sensitive information and messages (such as the Krabby Patty Formula) securely enough that Karen can’t crack them? We use something called 256-bit encryption, one of the most secure methods right now. Why 256-bit? Well, 256 is the length of the encryption key used to encrypt a file or data stream. The reason it works is because there are too many possibilities to compute in a reasonable amount of time, specifically 2²⁵⁶. Using even the world’s fastest computers, computing these possibilities is virtually impossible.

What’s even better is that using longer keys doesn’t make the encryption process that much harder, but it exponentially increases the difficulty of decrypting information, as the number of guesses it would take to crack a cipher shoots skyward.

Okay, if longer keys are more secure, why don’t we use 10,000 bit keys? 100,000 bit? 1,000,000 bit?? Well, it’s a performance tradeoff. Longer bits mean a longer time to access information and sites securely, which will result in lack of users. Thus, encryption methods must balance security and performance in order to use cryptography practically.

Now, this is barely a scratch on the surface of all the secrets cryptography holds. In general, there are four primary types of cryptography: symmetric, asymmetric, hashing, and key exchange. Today, we’ve touched on symmetric cryptography and a teeny tiny bit on asymmetric. The most traditional form is symmetric encryption, which is when the same key (previously agreed upon by both parties) is used to encrypt and decrypt messages, such as in Caesar’s Cipher and Vigenère’s cipher. (In future columns, we’ll talk about the other types and the history of more advanced encryption methods such as Diffie-Hellman, RSA, and more!)

However, on the Internet, it is clearly impossible for any two computers to “meet” in private and agree upon a secret key to encrypt and decrypt messages. So, instead, they use asymmetric encryption. In this type of encryption, there are different keys for encrypting and decrypting. There is a public key that can be exchanged with anyone, which is used to encrypt a message and that anybody can use to create a secret message. Then, there is a private key that is not shared, and the secret can only be decrypted by a computer with access to the corresponding private key.

As computers are becoming faster and faster, we need to start developing new ways to make encryption too hard for computers like Karen to break. But hopefully Taylor doesn’t join in on this, finding and deciphering her messages is hard enough as is.

So there you have it folks, my not-so-secret motivation for this column! I hope we can all put these basic methods to use and accurately figure out what Miss Swift is trying to say to us. In the meanwhile, eagerly wait for the next album by streaming folklore and evermore! I also have a sneaking suspicion that current up-and-comer Olivia Rodrigo is taking after Taylor Swift and is leaving secret clues for her fans–does anyone else think her next album will be called Sweet? Seems a little suspicious… Case in point, we must exercise constant vigilance!

Until next time! If you found this interesting, make sure to check out the next column! If you have any questions or comments, please email me at apoorvapwrites@gmail.com.

To be the first one to hear about all my new articles, recent events, and latest projects, make sure to subscribe to my newsletter: Letter? I Hardly Know Her!

This column, Gems in STEM, is a place to learn about various STEM topics that I find exciting, and that I hope will excite you too! It will always be written to be fairly accessible, so you don’t have to worry about not having background knowledge. However, it does occasionally get more advanced towards the end. Thanks for reading!

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

{UPDATE} Cutemii Hack Free Resources Generator

Which is easier to teach: DCO or Threat Intelligence?

Guide to AWS Penetration Testing

Equipping Developers to ship with Privacy by Design built in

Removing all Smart Contract Risk & Tech Team Tokens

Getting EasyFi Secure Again

The Mysterious Case of the Powershell that Didn’t Look Like Powershell

How to verify container images with Kyverno using KMS, Cosign, and Workload Identity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Apoorva Panidapu

Apoorva Panidapu

17 y/o math student, artist, and advocate for youth & gender minorities in STEAM. Winner of Strogatz Prize for Math Communication & Davidson Fellows Laureate.

More from Medium

Finance Part 1: Introduction

Introduction to Cooperative Autonomous Multi-Robot Systems

Robotics driven by artificial intelligence

Square Root of 16 “ TOP FUTURE POINT