Computer Science · CSTA 2-DA-07 · 2-NI-06 · 信息科技 · Data & codes

Data, codes & encryption: everything is numbers — even secrets

Every photo, message and emoji on your phone is, in the end, a string of 0s and 1s. So here’s the problem: what if someone grabs those numbers on the way? Over 2,000 years ago Julius Caesar hid messages by shifting each letter 3 places. In World War II, codebreakers who cracked Germany’s Enigma machine helped shorten the war. Today, every time you see the little padlock in your browser, encryption is at work.

Your mission: start as a code clerk. Turn words and pictures into numbers, spin a Caesar cipher wheel, then crack five intercepted messages with frequency analysis to become Master Cryptanalyst. Finally, learn to show data clearly with charts — without being fooled.

Sim 1: how words and pictures become numbers

A computer only stores 0s and 1s (binary). Eight bits make one byte, which can hold any number from 0 to 255 — 256 values. Every character has a code number, and every pixel is three numbers: red, green and blue.

🔤 Text → code numbers → binary

0characters
0bytes (UTF-8)
0bits
Why does one Chinese character need 3 bytes?

Early ASCII (1963) had only 128 characters — English letters, digits and symbols — so one byte was plenty. Unicode numbers the writing of the whole world, including tens of thousands of Chinese characters and the emoji: over 150,000 characters. UTF-8, the most common way to store it, keeps English letters at 1 byte, common Chinese characters at 3 bytes and emoji at 4.

🎨 Pixel editor: every dot is three numbers

64pixels (8×8)
192bytes (3 per pixel)
0colours used

A 12-megapixel phone photo: 12 million × 3 bytes ≈ 36 MB — that’s why photos are compressed (e.g. JPEG) before they are saved.

🎯 Colour challenge: mix the target with three numbers

target colouryour colour (use the sliders above)
0%match
0solved
—hint

Sim 2: the Caesar wheel and the Vigenère cipher

Drag the inner ring (or use the slider) to set the key — how many places each letter shifts. Turning plain text into cipher text is encryption; turning it back is decryption.

Advanced: the maths, letter fingerprints, a tiny public key and a hash
🔨 Brute force: try all 25 keys
🔐 A tiny public-key cipher (RSA with small primes)
#️⃣ Hashing: a fingerprint of the data
🎯 Challenge

Main mission: codebreaker — crack intercepted messages with frequency analysis

Each message is encrypted with a Caesar cipher — key unknown. In English, E is the most common letter, then T, A, O… Count which letter appears most in the message and you can guess the key! Drag the slider until the grey “English” bars line up with the blue “message” bars, then submit. No hints and right first time = 3 stars.

0total stars
1/5message
☆☆☆this message
—rank
📡 Intercepted message:
🔓 Decrypted with this key:

Grey bars: average frequency of letters in English (%, approximate, widely used table after Lewand, 2000). The messages are in English — the Caesar cipher only shifts the 26 letters A–Z.

Sim 3: turn data into a chart — pick the right one, don’t get fooled

Edit the table (example data: a class survey, “How do you most often message friends?”), choose a chart type and see which one fits best. Then switch on “sneaky mode”: when the axis doesn’t start at 0, differences look much bigger than they are!

0total
—most popular
0mean per item

Go further

Test yourself

🧠 Quiz

Pick the best answer and read the explanation.

🗂️ Sort it: encoding, encryption or charts?

Drag each item (or tap it, then tap a box) into the right group.

👩‍🏫 Teacher notes

US standards: CSTA K-12 CS Standards (2017), grades 6–8 — 2-DA-07 (represent data using multiple encoding schemes), 2-DA-08 (collect data with computational tools and transform it to be more useful and reliable), 2-NI-06 (apply multiple methods of encryption to model the secure transmission of information), 2-IC-23 (tradeoffs between public and private information). Georgia K-12 Computer Science Standards (6–8), e.g. CSS.KC.6-8.20.3 (how computers represent data and media), 15.1–15.3 (spreadsheet formulas, charts and data tools to predict and conclude), 17.1–17.3 (interpret others’ charts, choose appropriate visuals, design clear visualizations), CSS.DC.6-8.12.2 (cryptography, hashing, steganography). Codes as listed in GaDOE’s 6–8 CS framework (via CodeHS); check wording against the GaDOE document.

China’s curriculum: Compulsory Education Information Technology Curriculum Standards (2022) — Stage 2 (grades 3–4) module “Data and encoding” (数据与编码: encoding information, binary, encoding characters and images) and Stage 4 (grades 7–9) data security and encryption within “Internet applications and innovation”; logic strands “Data” (数据), “Information processing” (信息处理) and “Information security” (信息安全). The chart section links to the maths strand “Statistics and probability” (choosing bar, pie/sector and line charts).

Notes: English letter frequencies are approximate values from a widely used table (Lewand, 2000). The five messages and the survey data were written for this lesson. Caesar’s shift of 3, al-Kindi’s 9th-century description of frequency analysis, the Vigenère cipher resisting general attack for about 300 years Unicode’s 150,000+ characters and the Navajo code never being broken are standard statements written from the author’s knowledge — teachers may wish to verify. The colour-challenge “match” is straight-line distance in RGB space, not perceived colour difference.

Suggested use: pairs send each other Caesar messages with the wheel, then swap and crack them; discuss why codebreakers want long messages; use sneaky mode to discuss charts in news and adverts, and link to 2-IC-23: which personal information should be public, and which should be encrypted?