TwiddleLab / Code / How Computers Store Everything
Hide a Message in a Picture
What you will learn
- Steganography hides that a message exists at all, not just what it says.
- The least significant bit (the last bit) of a colour number changes it by only 1: invisible.
- 8 pixels' last bits make one byte, so 8 pixels hide one letter.
- Lossy saving, like JPEG, changes last bits and breaks the secret.
How the lesson goes
Two photos look exactly the same. One carries a secret message. Which one?
Tap your bet.
How much can a colour change before you notice?
Add a little to the red of one pixel, then a lot.
Look at only the last bit of every red number.
Use the lens on both pictures.
Steganography.
Steganography: hiding a message so nobody even knows it is there. Encryption hides the meaning; this hides the message.
The least significant bit is the last bit of a number. Flipping it changes red by just 1 out of 255.
One letter is one byte, 8 bits, so 8 pixels hide one letter.
How a computer reads a hidden letter.
Step through 8 pixels.
Hide the first letter of your own secret word.
Type a word, then tap pixels until their last bits spell its first letter.
Hide the rest of your word.
Each next letter goes into the next 8 pixels. Drag the letter bytes onto the strips, in order.
Spot the secret: 5 pairs, only 3 lenses.
Pick the picture with the secret in each pair. A saved lens is worth 10 points.
AI image makers can hide a 32 bit watermark that says "made by AI".
If each pixel hides 3 bits, one in the last bit of red, green and blue, how many pixels are needed?
A friend sent you a picture. Read the hidden word.
Tap each pixel to write down its last bit.
Which changes to a pixel would anyone see?
Colours go from 0 to 255.
Your friend opens your picture. One letter comes out wrong.
Find the pixel that broke and fix it.
Previous lesson: Secret Messages · Part of the course: How Computers Store Everything
Lessons are interactive and need JavaScript. Turn it on to play them.