Lesson №07 5th century BC to today 20 min
Steganography
A cipher hides what a letter says, but everyone can see there is a letter. Steganography hides the letter itself: under a messenger's hair, beneath wax, in the lowest bits of a photo, in a sound you can see.
In this lesson
- how steganography differs from encryption
- how null ciphers and the Cardan grille work
- what the least significant bit and a bit plane are
- how to paint a picture in sound and see it in a spectrogram
Around 499 BC the Greek tyrant Histiaeus was living at the Persian king's court, an honoured guest and, in truth, a prisoner. He needed to tell his son-in-law in Miletus to start a revolt. Any letter on the road would be searched. So Histiaeus shaved the head of his most trusted slave, pricked the message into his scalp, and waited for the hair to grow back. Then he sent the slave to Miletus with one spoken instruction: “Tell Aristagoras to shave my head and look.”
Herodotus wrote the story down. There is no cipher in it at all: the message on the scalp was written plainly. But no guard would think of looking for a letter under someone's hair. The secret was not what the message said but that there was a message.
Hiding the meaning, or hiding the letter
So far this course has been about cryptography, Greek for “secret writing”. A cipher turns text into gibberish. The enemy sees the gibberish, knows a secret is there, and can set about breaking it, or simply arrest the sender.
Steganography, “covered writing” from the Greek steganos, does something else. It hides the message inside something innocent: a picture, a letter about the weather, a piece of music. The interceptor sees a postcard from the seaside and lets it through, never knowing he let a report through too.
The word was coined by the German abbot Johannes Trithemius, whose book “Steganographia” was written around 1499. The book was itself steganography: it looked like a treatise on magic and summoning spirits, and was really about ciphers.
The two approaches don't compete; they stack. A sensible spy encrypts the report first and then hides the cipher text. If the hiding place is found, the text still can't be read. If it isn't, nobody even learns there was a correspondence.
Herodotus tells a second story. Demaratus, a Spartan exile living among the Persians, learned that King Xerxes was preparing to invade Greece. He took a wooden writing tablet, scraped off the wax, wrote his warning on the bare wood and covered it with wax again. A blank tablet passed every checkpoint. In Sparta nobody could work out what it meant until Gorgo, the wife of King Leonidas, thought of scraping off the wax.
Invisible ink
The trick everyone learns at school: write with milk or lemon juice, then write an ordinary letter in ink between the lines. Dried juice is invisible, but it browns before the paper does when heated, and the text appears. The Roman writer Pliny the Elder already mentioned a plant juice used as invisible ink.
In the First World War invisible ink became a serious weapon. Spies wrote with chemicals that only showed up with another reagent, and censors tested suspicious letters with iodine vapour and ultraviolet light. The subject stayed sensitive for a remarkably long time: in 2011 the CIA declassified its oldest classified documents, memos from 1917 and 1918 about secret ink formulas.
In the Second World War German agents went further, shrinking a whole page photographically to the size of a printed full stop. Such a microdot was glued into an ordinary letter in place of a dot.
The null cipher: a letter inside a letter
You can do without chemistry altogether. Just agree which letters to read. This is a null cipher: nearly every letter is a “null”, a dummy, and only some carry meaning. The first letter of each word, say, or the second, or every third word.
Read the second letter of each word and the cable says “Pershing sails from NY June 1”. General John J. Pershing commanded the American forces bound for Europe. The trouble with such cables is visible too: “ejecting suets” is a strange thing to write, and strange phrases are exactly what censors look for.
The Cardan grille, described by the Italian mathematician Gerolamo Cardano in 1550, works in a similar way. Sender and receiver have identical cards with holes cut in them. The sender lays the card on the paper, writes the secret words in the holes, removes the card and writes an innocent letter around them. The receiver lays his card on top and sees only what matters.
And in the early 17th century Francis Bacon worked out how to hide a letter in the typeface of a text. Each secret letter is written as five marks of two kinds, A and B, and the A's and B's become two slightly different fonts. Any text set in two fonts can carry a second letter. Try Bacon's cipher.
An agent on holiday sends a one-line note. This time the rule is the simplest one of all. Where is the meeting?
Bring raincoats; it’s damp, grey everywhere.
Forget the second letters: the rule here is simpler than the Pershing cable's.
Write down the first letter of each word: “Bring” gives B, “raincoats” gives R…
First letters: Bring raincoats; it’s damp, grey everywhere. That spells bridge.
This one reads naturally because the message is short. The longer the hidden message, the harder it is to write a natural letter around it, which is why null ciphers suit short messages only. A censor who suspects one simply tries the usual rules, exactly as you just did.
Pixels: a hiding place in the lowest bit
Computers opened up a vast space for steganography. A digital photograph is a table of numbers. Each pixel holds three of them: how much red, green and blue it has, from 0 to 255. A pixel of night sky might be (24, 38, 92), a deep blue.
A number from 0 to 255 is written with eight binary digits, or bits. 92 is 01011100. The leftmost bit is the most significant: it is worth 128, and flipping it nearly doubles or halves the colour. The rightmost is the least significant bit, the LSB: it is worth 1. Flip it, and 92 becomes 93. No eye, and few screens, can tell the difference.
So the lowest bit of every number can be handed over to a message. The eye sees a photograph; a program that knows where to look reads the message. Collect the same bit from every pixel into a black-and-white picture and you get a bit plane.
Walk through the planes. In the high bits you see the photo itself: hills, moon, the sky's gradient. The lower the bit, the more noise, because a picture's grain lives down there. And in blue bit 0, neat letters stand out from the noise. That is exactly how the sixth door of our quest works.
How much fits? A 360 × 240 image has three numbers per pixel: 259,200 low bits, or 32,400 bytes. That is about 32,000 English letters, a short story in a small picture. The steganography tool hides text this way and gets it back out.
Low bits survive only lossless formats such as PNG. Save the picture as JPEG, or send it through an app that recompresses images, and the low bits get scrambled and the message is gone.
Why hide a message in the lowest bit rather than the highest?
The highest bit is worth 128: replacing it turns a deep blue sky pale. The lowest is worth 1, and the picture stays as it was. And the low bits of a real photo already look like noise, so the message bits don't stand out.
A sound you can see
Any sound can be broken down into a sum of pure tones, sine waves of different pitch. A rumble is low frequencies, a whistle high ones. A spectrogram shows which frequencies sound at each moment: time runs left to right, pitch bottom to top, and brightness shows loudness.
That leads to a simple idea: if a spectrogram is a picture, a sound can be painted. Take an image, turn each row into a band of frequencies and each column into a slice of time. Wherever a pixel is lit, the tones of its band sound. The ear hears hiss and squeaks; the spectrogram shows the image.
The most famous example comes from the British musician Richard D. James, better known as Aphex Twin. In 1999 his single “Windowlicker” included a second track titled with a mathematical formula, usually called “Equation” or “Formula”. Near the end of the track, the musician's own face appears in its spectrogram. A listener hears grinding noise and suspects nothing.
The fifth door of the quest works the same way: a word written in the sound in block letters between 1800 and 7200 hertz. To read it, load the file into the spectrogram viewer.
How hidden things are found
Steganography relies on the enemy not knowing where to look. That is a weak footing: once the method is known, the hiding place opens at once. So there is an opposite craft, steganalysis, the search for hidden messages.
A steganalyst doesn't read the message; she notices traces. The low bits of a real photograph have a faint link to their neighbours: sensor noise and compression leave a pattern. Random message bits destroy that pattern, and statistical tests catch it. Sharp edges, like the letters in our widget, can even be seen by eye once you think of looking at the plane.
Steganography is around us today, often unnoticed. Many colour laser printers add a faint pattern of yellow dots to every page, encoding the printer's serial number and the time of printing. In 2005 the Electronic Frontier Foundation published how to decode the pattern of one such printer line.
Another photograph has been intercepted. The analyst has already checked blue bit 0 and found nothing. But there is a word in the picture. What is it?
Go through the planes in order: for each channel, the low bits 0, 1 and 2. Hiding in the high bits is pointless; that is where the photo itself shows.
Try the red channel.
In the red channel, bit 1, the word BADGER appears. Bit 1 is worth 2, so no number changed by more than 2 in 255: still invisible.
The lesson: going through all 24 planes takes a minute. Hiding “somewhere unusual” barely helps if the enemy knows the technique. That is why steganography is paired with encryption: then even bits that are found look like noise.
What to take with you
- A cipher hides the meaning; steganography hides the fact that there is a message. They work best together: encrypt first, then hide.
- A null cipher picks the right letters out of an innocent text: first letters, second letters, every third word. Good for short messages.
- A pixel's lowest bit changes its colour by 1 in 255, which no eye can see. One bit of every pixel makes a bit plane, where hidden things often show at once.
- A spectrogram turns sound into a picture, so a picture can be turned into sound.
- Steganography holds only as long as the method is unknown. On its own it is hide-and-seek, not protection.
Invisible ink, microdots and null ciphers worked while letters were on paper. In the 20th century most traffic moved to radio, and anyone can listen to radio. There was nowhere left to hide, and cipher machines took the stage. Next: the Enigma machine →
Tools for this lesson
Everything from the lesson, working: paste your own text.
- Image steganography (LSB) Hide text in the least significant bits of a PNG and get it back; view an image’s bit planes.
- Audio spectrogram viewer See the spectrogram of an audio file and hide your own picture or text in a sound.
- Bacon’s cipher Francis Bacon’s cipher: each letter becomes five A/B marks that can hide in the typeface of an innocent text.