🎉 Heading to EuroPython 2026? Check out my poster on Django TDD Patterns & read the full visual field guide here.

Secret Messages: Understanding Encryption vs. Hashing Through a 90s Love Story

The year was 1998. A time of dial-up internet, boy bands, and passing notes in class. For 16-year-old Alex and Jamie, passing notes was their lifeline—a private channel in a world where their parents monitored everything from phone calls to AOL Instant Messenger. It began innocently enough. Folded notebook paper slipped between textbooks during class changes. Messages hidden in borrowed CDs. Notes taped under cafeteria tables to be retrieved later. "Meet me at the mall on Saturday? My dad can

Secret Messages: Understanding Encryption vs. Hashing Through a 90s Love Story
Contents

The year was 1998. A time of dial-up internet, boy bands, and passing notes in class. For 16-year-old Alex and Jamie, passing notes was their lifeline—a private channel in a world where their parents monitored everything from phone calls to AOL Instant Messenger.

It began innocently enough. Folded notebook paper slipped between textbooks during class changes. Messages hidden in borrowed CDs. Notes taped under cafeteria tables to be retrieved later.

“Meet me at the mall on Saturday? My dad can drop us off at the movie theater. –Alex”

“Can’t wait! I told my mom I’m studying with Melissa. Pick me up at the library instead. –Jamie”

For two months, their system worked flawlessly. Until that fateful day when Jamie’s mother decided to clean out her backpack.

“What’s this?” her mother demanded, unfolding one of Alex’s notes. “Who is this Alex, and why are you lying about studying with Melissa?”

Across town, a similar scene played out in Alex’s home.

“You’re grounded for two weeks,” Alex’s father announced after discovering a stack of notes hidden between CD cases. “And we’re going to have a serious talk about this dishonesty.”

Simple Substitution

A week into their grounding, Alex had an epiphany while playing a video game. What if they could write messages that looked like nonsense to their parents but made perfect sense to each other?

During a carefully monitored phone call about “homework,” Alex proposed the idea.

“Remember how we used to make up secret codes in elementary school? What if we substitute each letter with something else? A becomes Z, B becomes Y, and so on.”

Alex & Jamie’s Secret Code (1998)

MEET ME AT THE BASKETBALL COURT AFTER SCHOOL

Encode Message Decode Message Reset

In the story, Alex and Jamie used a simple substitution cipher where A becomes Z, B becomes Y, etc. This is known as an “Atbash cipher” - a type of monoalphabetic substitution cipher.

Their first encrypted message passed hands in biology class the next day:

“NVVG NV ZG GSV YZHPVGYZO XLFIG ZUGVI HXSLLO”

Which translated to

“MEET ME AT THE BASKETBALL COURT AFTER SCHOOL”

For a few glorious weeks, their communication flowed freely again. Jamie’s mother found one of the notes but dismissed it as “teenage gibberish.” Alex’s father was equally baffled: “Is this some new text-speak I don’t understand?”

But their victory was short-lived. One evening, Jamie’s mother, a crossword puzzle enthusiast, spent an hour with one of the notes and cracked their simple substitution cipher. Worse still, instead of confronting them, she decided to have some fun.

Alex received a note seemingly from Jamie: “XZMG NVVG GSZG WZB. R WLMG ORPV BLF GSZG NFXS ZMBDZB.”

When decrypted: “CANT MEET THAT DAY. I DONT LIKE YOU THAT MUCH ANYWAY.”

Alex was devastated—until the real Jamie, confused by Alex’s sudden coldness, confronted him directly.

“My mom,” Jamie groaned when Alex showed her the note. “She must have figured out our code.”

The Two-Formula System

That weekend, while serving the extended grounding their deception had earned, Alex spent hours in the family’s computer room researching more sophisticated secret codes. A mathematics website gave Alex an interesting idea.

“I think I’ve got it,” Alex explained during a hushed conversation between classes. “Our problem is that we’re using the same pattern to scramble and unscramble our notes. What if we each had two different formulas instead?”

Jamie looked skeptical. “How would that even work?”

“It’s like this: I create two mathematical formulas that are related. I give you one formula—let’s call it my ’locking formula’—which you use to scramble messages to me. But I keep a different formula—my ‘unlocking formula’—that’s the only way to unscramble those messages.”

“So even if my mom finds your locking formula…”

“Exactly! She can only use it to scramble messages, not to read them or fake messages from me. She’d need my unlocking formula for that, which I never share with anyone.”

Their new system was more complex but worth the effort. They created their formulas using a mathematical approach Alex found in a puzzle book, simplified for their paper-based communications.

Alex & Jamie’s Two-Formula System

Sending as:

Alex sending to Jamie Jamie sending to Alex

Original Message:

I MISS YOU

Encoding Steps:

  1. Convert letters to numbers:

  2. Apply locking formula:

  3. Convert back to letters:

Encoded Message:

Decoding Steps:

  1. Convert letters to numbers:

  2. Apply unlocking formula:

  3. Convert back to letters:

Encode Message Decode Message Reset

Alex and Jamie’s two-formula system uses separate formulas for encoding and decoding messages. This is conceptually similar to modern public-key cryptography.

Jamie’s locking formula: “Multiply by 7, then add 3” Jamie’s unlocking formula: “Subtract 3, then divide by 7”

Alex’s locking formula: “Multiply by 5, then add 8” Alex’s unlocking formula: “Subtract 8, then divide by 5”

To send a message, they would convert letters to numbers (A=1, B=2, etc.), apply the recipient’s locking formula to each number, and then convert back to letters.

When Jamie’s mother found another note and tried to modify it, the tampering was immediately obvious because she couldn’t properly encode her fake message without knowing Alex’s secret unlocking formula.

Adding a Message Checksum

Their two-formula system worked beautifully for ensuring privacy, but a new problem emerged: Jamie’s younger brother found it hilarious to add extra symbols or cross out parts of their notes before they reached their destination.

“How do we know if someone has changed even a tiny part of our message?” Jamie wondered.

Alex had been reading more about mathematical puzzles. “We need to add a kind of verification code—like a special signature that changes if anyone messes with our message.”

“How would that work?”

“Imagine I take our message and run all the letters through a simple math formula that gives a two-digit number—like a unique fingerprint. I write this number at the end of my scrambled message. When you receive it, you run the same formula on the message and check if you get the same number. If even one letter is different, the number won’t match.”

They devised a simple formula: Add up the numerical values of all characters in the message, multiply by 13, and take the remainder when divided by 100.

Alex & Jamie’s Message Verification System

Original Message:

MEET ME TOMORROW

Try editing the message to see how the verification code changes!

Verification Code Calculation:

  1. Convert letters to numbers and add them:

  2. Multiply the sum by 13:

  3. Get the remainder when divided by 100:

Message with Verification Code:

VC:

What if Jamie’s brother changes the message?

Tampered Message:

Make a small change to see how it affects the verification code!

New Verification Code Calculation:

Original Verification Code: New Verification Code:

Calculate Verification Code Test Tampering Reset

This verification code system is similar to modern “hash functions” that create digital fingerprints of messages. Any change to the message, no matter how small, creates a completely different verification code.

Scrambled message: “FJWLM XYZPT ABCDE” Verification code: “62”

If Jamie’s brother changed even one letter, the verification code would calculate differently, and they would know the message had been tampered with.

By the time they graduated high school, Alex and Jamie had developed a communication system sophisticated enough to baffle their parents and siblings: their two-formula system for privacy combined with verification codes for message integrity.

Years later, when Alex became a software engineer and Jamie a cybersecurity analyst, they would laugh about how their teenage romance had inadvertently launched their careers in information security.

“You know,” Alex would say during a cybersecurity conference they both attended, “what we called our ’locking and unlocking formulas’ back then is actually what professionals call public key and private key cryptography.”

Jamie would smile. “And our ‘verification code’ is basically what we now know as a hash function.”

From Love Notes to Digital Security: Understanding the Concepts

The story of Alex and Jamie mirrors the evolution of modern cryptography. What began as simple substitution ciphers thousands of years ago has evolved into the sophisticated encryption and hashing algorithms that protect our digital lives today.

Let’s break down these concepts, starting where Alex and Jamie did.

Encryption: Keeping Secrets Secret

What is Encryption?

Encryption is the process of converting information (plaintext) into an unreadable form (ciphertext) to prevent unauthorized access. Think of it as putting your message in a locked box.

In our story, Alex and Jamie started with a simple substitution cipher—replacing each letter with another according to a pattern. This is actually one of the oldest forms of encryption, dating back to Julius Caesar.

Symmetric Encryption (Single-Key Encryption)

This is what Alex and Jamie first attempted with their letter substitution scheme. In symmetric encryption, the same key is used for both encryption and decryption.

Imagine you have a special diary with a lock. You and your friend both have identical keys. When you want to share a secret, you write it in the diary, lock it, and give it to your friend. Your friend uses their matching key to unlock it and read the message.

Modern symmetric encryption algorithms include:

  • AES (Advanced Encryption Standard)
  • DES (Data Encryption Standard)
  • Blowfish

The main weakness? Key distribution. Somehow, you need to securely share the key with the intended recipient. If someone intercepts the key, they can read all your messages—just like Jamie’s mother figured out their substitution pattern.

Asymmetric Encryption (Public-Key Encryption)

This is the breakthrough Alex and Jamie discovered. Asymmetric encryption uses two mathematically related keys:

  • A public key that can be freely shared
  • A private key that must be kept secret

When someone wants to send you a secret message, they encrypt it using your public key. Once encrypted, the message can only be decrypted using your private key.

It’s like having a special mailbox with two keys: one key (public) that only lets people put mail in, and another key (private) that only lets you take mail out. Anyone can deposit, but only you can retrieve.

Modern asymmetric encryption algorithms include:

  • RSA (named after Rivest, Shamir, and Adleman)
  • ECC (Elliptic Curve Cryptography)
  • DSA (Digital Signature Algorithm)

In practice, asymmetric encryption is often used to exchange symmetric keys securely. Why? Because asymmetric encryption is computationally expensive and slower for large amounts of data.

How Encryption Works in Real Life

When you visit a website with HTTPS (notice the padlock in your browser), you’re using encryption. Your browser and the website server perform a secure handshake using asymmetric encryption to establish a symmetric key for that session.

When you use WhatsApp or Signal, your messages are encrypted end-to-end, meaning only you and the recipient can read them—not even the service provider.

Understanding Encryption: Interactive Explainer

Symmetric Encryption Asymmetric Encryption

Your Secret Message:

Sender

👩‍💻

Recipient

👨‍💻

Hello, this is a secret message!

Zft7i$kd9Q@4pL!

Hello, this is a secret message!

Hacker

🕵️‍♀️

Symmetric Encryption

In symmetric encryption, the same key is used for both encryption and decryption. It’s like a door where everyone who needs access uses copies of the same key.

Advantages:

Challenges:

Examples:

Animate Encryption Process Reset

Hashing: Digital Fingerprints

What is Hashing?

Hashing is the process of converting input data of any size into a fixed-size string of characters, which typically appears as a random mix of numbers and letters. Unlike encryption, hashing is a one-way function—you cannot convert the hash back to the original data.

In our story, Alex and Jamie used a simple hash function to verify message integrity. They couldn’t recover the original message from the hash, but they could tell if the message had been altered.

Key Properties of Hash Functions

  1. Deterministic: The same input always produces the same hash output
  2. Quick Computation: It’s efficient to calculate the hash for any input
  3. Pre-image Resistance: Given a hash, it should be infeasible to find the original input
  4. Small Changes Cause Big Differences: Changing even one character drastically changes the hash
  5. Collision Resistance: It should be extremely difficult to find two different inputs that produce the same hash

Common Hash Functions

  • MD5 (Message Digest Algorithm 5) – No longer considered secure
  • SHA-1 (Secure Hash Algorithm 1) – Also deprecated for security applications
  • SHA-256 (part of the SHA-2 family) – Widely used today
  • bcrypt and Argon2 – Specialized for password hashing

Below are some real world application for the same

Password Storage

When you create a password on a website, the site doesn’t (or shouldn’t) store your actual password. Instead, it stores a hash of your password. When you log in, the site hashes what you enter and compares it to the stored hash.

Even if hackers steal the database, they only get hashes, not actual passwords. And remember—you can’t reverse a hash to get the original input.

File Integrity

When you download software, websites often provide a hash value. After downloading, you can calculate the hash of your file and compare it to the provided hash to ensure the file wasn’t corrupted or tampered with during download.

Digital Signatures

Digital signatures combine hashing and asymmetric encryption. First, a hash of the document is created. Then, the sender encrypts that hash with their private key. Anyone with the sender’s public key can decrypt the hash and verify the document hasn’t been altered.

Blockchain Technology

Cryptocurrencies like Bitcoin rely heavily on hash functions. Each block contains a hash of the previous block, creating a chain where any tampering would be immediately evident.

Understanding Hashing: Digital Fingerprints

Enter any text:

Hello, this is my message!

Simple Hash MD5-like SHA256-like

Hashing Process

Original Input:

Hello, this is my message!

Hash Function

sum(char_codes) * 31 % 255

Hash Output:

a72ee7

Hash Function Properties

Property 1: Small changes cause drastic hash differences

99e5c

53a3f

Changing just one letter completely changes the hash!

Property 2: Fixed output length regardless of input size

Short input: “hi”

4492d

Medium input: “Hello, world!”

2cf2d8

Long input: “This is a much longer message that would take many more bytes…”

a8f71c

Property 3: One-way function (cannot reverse a hash)

Original Password

Tr0ub4dor&3

Stored Hash

e36bb9c1745f80801237e5d8ff803bf2

Even if an attacker steals the hash, they can’t convert it back to your password. They’d have to try guessing passwords and hashing each guess.

Real-World Applications of Hashing

Password Storage File Integrity Blockchain

How websites store your passwords:

  1. When you create an account, the site hashes your password
  2. Only the hash is stored in the database, not your actual password
  3. When you log in, the site hashes what you type and compares it to the stored hash
  4. If the hashes match, you’re granted access

Why this is secure:

  • If hackers steal the database, they only get hashes, not passwords
  • One-way nature means hackers can’t reverse the hashes
  • Modern password hashing also uses “salt” to prevent rainbow table attacks

Database Example

username: alice

password: 8a7d3b…

username: bob

password: f92c1a…

username: carol

password: 3e9b2f…

How file integrity checks work:

  1. Software developer computes a hash of their program file
  2. The hash is published alongside download links
  3. After downloading, users can compute the hash of their downloaded file
  4. If the hashes match, the file wasn’t corrupted or tampered with

Why this is useful:

  • Detects accidental corruption during download
  • Prevents malicious code injection by hackers
  • Ensures software integrity without complex verification

Download Page Example

Download v2.1.4

MD5:

8a7b3cd97f4e…

SHA-256:

3f7b9a1c5d2e…

How blockchain uses hashing:

  1. Each block contains transaction data and the previous block’s hash
  2. The entire block is hashed to create a unique identifier
  3. This hash becomes part of the next block, creating a chain
  4. Any attempt to alter a block would change its hash, breaking the chain

Why this makes blockchain secure:

  • Creates an immutable record of transactions
  • Tampering is immediately evident and rejected by the network
  • Proof-of-work involves finding special hash values, securing the network

Blockchain Structure

Block #392

prevHash: 8fc4a…

[Transaction data]

hash: 37e9b…

Block #393

prevHash: 37e9b…

[Transaction data]

hash: 2df7c…

Block #394

prevHash: 2df7c…

[Transaction data]

hash: a4b8e…

Encryption vs. Hashing: Key Differences

Now that we understand both concepts, let’s clarify the main differences:

  1. Reversibility
    • Encryption is reversible; with the correct key, you can decrypt ciphertext back to plaintext
    • Hashing is one-way; you cannot recover the original input from its hash
  2. Purpose
    • Encryption provides confidentiality (keeping secrets secret)
    • Hashing provides integrity (ensuring data hasn’t been altered)
  3. Keys
    • Encryption requires keys for both encryption and decryption
    • Hashing doesn’t use keys (though there are variants like HMACs that do)
  4. Output Size
    • Encryption output size varies with the input size
    • Hash output has a fixed size regardless of input size

When to Use Encryption vs. Hashing

Use Encryption When:

  • You need to keep information confidential
  • The information needs to be retrieved and read later
  • You’re storing sensitive data that must be accessed in its original form
  • You’re sending private messages

Use Hashing When:

  • You need to verify data integrity
  • You’re storing passwords
  • You need to compare data without revealing the actual content
  • You need a fixed-size identifier for variable-length data

How They Work Together

Just like in Alex and Jamie’s final system, encryption and hashing often work together in modern security systems:

  1. Secure Communication
    • Hash the message to create a digital fingerprint
    • Encrypt both the message and its hash with the recipient’s public key
    • The recipient decrypts the message, calculates its hash, and compares it with the decrypted hash to verify integrity
  2. Digital Signatures
    • Hash the document to create a fixed-size digest
    • Encrypt the hash with your private key to create a signature
    • Others can verify the signature by decrypting it with your public key and comparing the result to a newly calculated hash of the document
  3. Password-Based Encryption
    • Hash a password to create a fixed-size encryption key
    • Use this key for symmetric encryption

Conclusion

As we’ve seen through Alex and Jamie’s journey, encryption and hashing solve different but complementary problems in information security. Their teenage attempts at secret communication mirror the actual evolution of cryptographic techniques that now protect everything from your text messages to your financial transactions.

Encryption ensures that your secrets remain secret by making them unreadable to anyone without the proper key. It’s like the locked diary that only you and trusted friends can open.

Hashing ensures that information hasn’t been tampered with by creating a unique digital fingerprint that changes completely if even a single character is modified. It’s like the wax seal on medieval letters that would break if someone tried to open the message.

Together, these technologies form the backbone of digital trust in our interconnected world. Every time you make an online purchase, log into a website, or send a secure message, you’re benefiting from the same principles that Alex and Jamie discovered through their passing of notes.

In a world where data breaches and privacy concerns dominate headlines, understanding these basic security concepts isn’t just for computer scientists or teenage sweethearts passing notes—it’s becoming essential knowledge for everyone participating in digital life.

The next time you see that little padlock in your browser or enter a password on a website, remember Alex and Jamie and their journey from simple substitution ciphers to the foundations of modern cryptography. Sometimes, the best innovations start with a simple problem: how to share a secret.