# The Secret Language

Codes, Ciphers and the Idea of Information

## 1. The Message That Nobody Was Supposed to Read

The message consisted of twenty-three characters.

There was no signature, no address and no explanation. It had been discovered inside an old book, written in an unfamiliar arrangement of letters.

Most people who examined it assumed that it was meaningless.

The letters formed no recognisable words. There were no spaces or punctuation marks. Nothing indicated where one word ended and another began.

But one observer noticed something interesting.

A particular letter appeared more frequently than the others.

Another pair of letters appeared together several times.

And a sequence of three characters occurred twice.

Perhaps the message was not random.

Perhaps it was written in English, but with the letters disguised.

The observer began counting.

Half an hour later, the message had surrendered its secret.

It described a location, a time and an instruction.

A meeting was to take place at midnight.

This scene is fictional, but the technique is real.

A message can be concealed by replacing its letters with other symbols. Someone who recognises the underlying patterns may be able to reverse the process.

The discovery may seem magical, particularly when a detective solves such a puzzle in a few pages.

Yet the method rests on an important observation.

Languages possess statistical structure.

Letters do not occur equally often. Certain pairs are common. Others are unusual. Words have characteristic lengths and patterns.

Even when the visible symbols are changed, some of these relationships may survive.

A person who understands those relationships can sometimes reconstruct the original message.

That idea forms a bridge between detective fiction and computer science.

In this chapter, we will follow it from Edgar Allan Poe's treasure puzzles to Sherlock Holmes's dancing figures, then onwards to binary encoding and Claude Shannon's mathematical theory of information.

Along the way, we will encounter an unexpected distinction.

A message can be represented without being understood.

It can be encrypted without becoming meaningless.

And its information content can be measured without anyone knowing what the message actually says.

These are three different properties.

Understanding their differences is essential to understanding the relationship between literature and computers.

## 2. Poe and the Mathematics of Treasure

In 1843, Edgar Allan Poe published The Gold-Bug.

The story follows William Legrand, an impoverished gentleman living on Sullivan's Island near Charleston, South Carolina.

Legrand becomes fascinated by an unusual beetle and a mysterious piece of parchment. Through a series of discoveries, he comes to believe that the parchment conceals instructions leading to buried treasure.

The crucial clue is a cryptogram: a message whose original letters have been replaced by other characters.

Legrand does not possess a secret codebook explaining the substitutions.

Instead, he must reconstruct them.

Poe turns the solution into a detailed demonstration of cryptanalysis, the process of studying and attempting to decipher concealed messages.

The fictional cryptogram contains numbers and punctuation-like symbols rather than ordinary alphabetical characters.

Legrand begins by examining their frequency.

He assumes that the underlying message is written in English. From there, he reasons that certain symbols may correspond to common English letters.

He studies repeated arrangements, short words and likely combinations.

Each discovery provides evidence for further deductions.

Eventually, the message can be read.

The deciphered instructions still require interpretation, but the cryptographic barrier has been overcome.

Poe's original text and the differences between its 1843 and 1845 versions can be examined in the Edgar Allan Poe Society's scholarly edition.

### Why Poe's method matters

The interesting feature is that Legrand does not guess the message character by character.

He uses knowledge about the statistical properties of language.

Poe's literary achievement was to turn cryptanalysis into dramatic action.

The detective's reasoning becomes part of the entertainment.

A reader is invited to follow the evidence and appreciate how apparently meaningless symbols reveal a hidden structure.

This technique would become influential in detective literature.

A mystery could now consist not merely of discovering who committed a crime, but of reconstructing information deliberately concealed by another person.

The story also establishes a recurring relationship between writer and reader.

The writer creates a pattern.

The reader attempts to discover it.

The pleasure arises partly from the moment when disorder becomes intelligible.

## 3. Why Some Letters Betray Their Secrets

Imagine replacing every letter in a sentence with another letter.

We might use the following rule:

Move each letter three places forward through the alphabet.

A becomes D.

B becomes E.

C becomes F.

And so on, wrapping around after Z.

This produces a Caesar cipher, the conventional name for this kind of alphabetic shift.

For example:

Original message:

`THE SECRET IS HERE`

Encrypted message:

`WKH VHFUHW LV KHUH`

The transformation is systematic.

Every T becomes W.

Every H becomes K.

Every E becomes H.

Because the same substitution is always applied, repeated letters remain repeated.

This is the weakness.

The cipher changes the appearance of the text without eliminating its underlying linguistic patterns.

In ordinary English, E is generally among the most common letters. T, A, O, I and N also appear frequently, although their exact ranking varies with the type and length of the text.

If a sufficiently long English message is encrypted using a fixed substitution alphabet, the most common ciphertext character may correspond to E.

But this is only a clue, not a certainty.

A short message might contain an unusually large number of another letter.

A scientific article, a poem and a shopping list can have different distributions.

A message deliberately constructed to avoid certain letters would create further difficulties.

Frequency analysis is therefore a method of inference rather than a guaranteed shortcut.

### A simple example

Consider the sentence:

`MEET ME AT THE GATE`

Ignoring spaces, the letter E occurs five times among fifteen letters.

Its observed frequency is:

f(E) = 5/15 = 1/3

That is approximately 33.3%.

This is much higher than the frequency of E in typical extended English prose.

The reason is that our sample is very short.

Now encrypt the sentence using a Caesar shift of three:

`PHHW PH DW WKH JDWH`

The ciphertext letter H occurs five times.

The high frequency has not disappeared.

It has merely moved from E to H.

That is why simple substitution ciphers are vulnerable.

Their symbols change, but their statistical fingerprints remain recognisable.

### A significant qualification

Frequency analysis works best when the message is sufficiently long and the encryption preserves useful statistical relationships.

Modern encryption methods are designed to avoid precisely this kind of leakage, along with many more sophisticated forms of attack.

A Caesar cipher or ordinary monoalphabetic substitution cipher is suitable for teaching and entertainment.

Neither should be used to protect confidential information.

The difference between a literary cryptogram and secure modern cryptography is enormous.

Yet the simple cipher remains valuable because it exposes the fundamental relationship between plaintext, ciphertext and the transformation connecting them.

![An Enigma machine with its keyboard, lampboard, plugboard and three rotor windows visible.](images/enigma.jpg)

Historical cipher hardware: an Enigma machine. Photograph by Joshbressers, 29 February 2016. [Source: Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Enigma_Machine.jpg), [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). Resized for this edition; no crop.

## 4. Sherlock Holmes and the Dancing Figures

Arthur Conan Doyle developed the literary possibilities of substitution ciphers further in The Adventure of the Dancing Men.

The story was first published in 1903 and later collected in The Return of Sherlock Holmes.

Hilton Cubitt seeks Holmes's assistance after strange drawings begin appearing near his home.

The drawings depict little human figures in different positions, as though they are dancing.

At first they resemble childish decorations.

But Cubitt's wife, Elsie, recognises something threatening about them.

Her reaction suggests that the figures are not innocent drawings.

Holmes begins examining them as a possible cipher.

Each distinctive figure may stand for a letter.

The drawings therefore operate as an alternative alphabet.

Holmes uses repeated figures, letter frequencies and contextual clues to reconstruct the concealed messages.

The story can be read in the original collection through Project Gutenberg.

### The significance of the disguise

Doyle's cipher is especially interesting because its symbols do not resemble ordinary writing.

A string of unfamiliar letters may immediately suggest an encrypted message.

Dancing human figures might instead appear decorative.

This is a form of concealment through presentation.

The message looks like something other than language.

The same principle appears in many forms of communication.

A message might be hidden inside an illustration, represented through coloured objects or encoded using musical notes.

But we must distinguish two techniques.

Encryption transforms information so that its contents cannot readily be recovered without the appropriate key or an effective attack.

Steganography attempts to conceal the existence of a message, or its presence within an otherwise innocent-looking carrier.

Doyle's dancing figures are primarily a substitution cipher. Their pictorial appearance also provides a degree of disguise, but that does not automatically make the entire method a robust steganographic system.

The distinction matters because hiding a message and encrypting it solve different problems.

If an adversary discovers that a picture contains a secret message, steganographic concealment may have failed.

But if the hidden message is also encrypted using a secure method, its contents may remain protected.

This is another step towards the modern science of information security.

Information has a content.

It has a representation.

And it may have a layer of protection.

These are related but different things.

### Holmes and the art of inference

Holmes's solution also illustrates the use of prior knowledge.

He does not treat every possible substitution as equally plausible.

He knows that English has common letters and characteristic word structures.

He possesses information about the people involved.

As the investigation develops, new clues narrow the possible interpretations.

This is an informal form of probabilistic reasoning.

A hypothesis becomes more credible when several independent observations support it.

But literary fiction simplifies the process.

A real cryptanalyst may need to test many competing hypotheses, examine ambiguities and reject plausible but incorrect readings.

Detective stories often compress this labour into a single brilliant revelation.

That is legitimate as storytelling.

It should not be mistaken for a claim that complicated cryptographic problems can always be solved through intuition alone.

:::lab cipher

## 5. Three Things That Look Like Code

The word code can refer to several different activities.

This creates confusion because everyday language uses it much more broadly than technical specialists do.

A secret message, a computer program and a system of symbols may all be described as codes.

But they perform different functions.

Consider the word:

`HELLO`

We could represent it using a different alphabet, transform it using encryption, or include it as data inside a computer program.

These operations are not equivalent.

### Representation

We might represent HELLO using numbers:

`72 69 76 76 79`

These are the decimal ASCII values of its uppercase letters.

Anyone familiar with ASCII can reconstruct the word.

The representation is not intended to provide secrecy.

### Encryption

We could apply a Caesar shift of three:

`KHOOR`

The purpose is to conceal the original text from someone who does not know the transformation.

However, the technique is trivial to break and provides no meaningful modern security.

### Programming

We could write:

```python
message = "HELLO"
print(message)
```

This is a program containing the word HELLO as data.

The program instructs a computer to display that data.

The word is neither hidden nor necessarily encrypted.

These distinctions are central to the second part of our study.

| Technique | Main purpose |
| --- | --- |
| Encoding | Represent information according to an agreed scheme |
| Encryption | Protect information from unauthorised interpretation |
| Programming | Specify operations for a computer to perform |
| Steganography | Conceal a message's presence or location |

A single system can combine several techniques.

For example, a program may read a Unicode text file, encrypt its contents and hide the resulting ciphertext inside an image.

But each step serves a different purpose.

Literature frequently exploits the ambiguity.

A mysterious series of symbols may be a concealed message, executable instructions, a fictional language or merely meaningless decoration.

The reader's challenge is to determine which.

![CAT represented as binary ASCII, or concealed as FDW with an insecure shift cipher; meaning still needs interpretation.](images/message-and-meaning.svg)

## 6. From Letters to Numbers

How does a computer represent the letter A?

At the lowest level, a conventional digital computer operates using physical states interpreted as binary values.

These values are represented as zeros and ones.

A single binary digit is called a bit.

Eight bits form a byte.

A byte can represent:

2⁸ = 256

different values.

Those values range from 0 to 255 when interpreted as unsigned binary integers.

But there is nothing inherently alphabetical about binary numbers.

A computer needs an agreed convention explaining which numerical values represent which characters.

One historically important convention is ASCII: the American Standard Code for Information Interchange.

ASCII was standardised in 1963 and established a common way to represent letters, digits, punctuation and control characters.

The familiar seven-bit ASCII repertoire contains 128 values, numbered from 0 to 127; the standard was revised after its first edition.

Under ASCII, uppercase A has decimal value 65.

In binary:

65 (decimal) = 01000001 (binary)

Thus the character A can be represented by the eight-bit pattern:

`01000001`

Strictly speaking, ASCII is a seven-bit code; we have shown its value using an eight-bit byte with a leading zero.

Now consider the word:

`CAT`

Its ASCII representation is:

| Character | Decimal value | Eight-bit binary |
| --- | --- | --- |
| C | 67 | `01000011` |
| A | 65 | `01000001` |
| T | 84 | `01010100` |

The complete byte sequence is:

`01000011 01000001 01010100`

The word has become a sequence of numbers.

But the transformation has not encrypted it.

Anyone who knows the encoding can reconstruct CAT.

This is the essential distinction between representation and secrecy.

The binary sequence is not mysterious to a computer.

It is simply a conventional way to store information.

### Why this matters to literature

Once letters can be represented numerically, a computer can manipulate written language without understanding its meaning.

It can store a novel.

Search for a particular phrase.

Count words.

Rearrange paragraphs.

Compare texts.

Generate new combinations.

Encrypt passages.

Or execute instructions that determine which words appear on a screen.

The machine does not need a human concept of storytelling to perform these operations.

It needs rules for manipulating representations.

This is the technical foundation upon which computational literature will eventually be built.

## 7. The Alphabet Becomes Universal

ASCII was enormously influential, but it had limitations.

Its original character set was designed primarily around English-language computing and associated control functions.

It could not represent the full range of characters used in the world's writing systems.

Languages use different alphabets, scripts, accents and symbols.

A Greek letter, an Arabic character, a Chinese ideograph and an accented French vowel cannot all be accommodated by ASCII's limited repertoire.

Different computer systems historically developed additional character sets and encodings.

Unfortunately, these were not always compatible.

A document created on one computer could display incorrectly on another because the same stored number might be interpreted according to different conventions.

The development of Unicode addressed the need for a more comprehensive and consistent representation of written characters.

Unicode assigns numerical code points to characters across many languages and symbol systems.

UTF-8 is one of the standard methods for encoding Unicode text into bytes.

It uses variable-length sequences of one to four bytes.

Ordinary ASCII characters retain their familiar single-byte values in UTF-8.

Many other characters require multiple bytes.

For example:

| Character | Unicode code point | UTF-8 bytes |
| --- | --- | --- |
| A | U+0041 | `41` |
| é | U+00E9 | `C3 A9` |
| € | U+20AC | `E2 82 AC` |

The hexadecimal values shown are byte values, not secret encryption keys.

Unicode is a system of representation, not a universal dictionary of meaning.

It tells computers which characters are being represented.

It does not tell them what those characters signify in a particular sentence.

This distinction opens a deeper question.

If a machine can store every symbol in every language, does it therefore understand those languages?

No.

Representing the written form of a language is not equivalent to understanding its grammar, cultural context or intended meaning.

We encountered a version of this distinction in Chapter One, when Swift's fictional machine rearranged words without understanding them.

Now we can describe the technical foundation of that process more precisely.

A computer can manipulate encoded text as information.

Whether the operation produces meaningful language is a separate matter.

## 8. Claude Shannon and the Birth of Information Theory

In 1948, the American mathematician and engineer Claude Shannon published A Mathematical Theory of Communication.

The paper appeared in two parts in The Bell System Technical Journal.

It established foundations for the modern mathematical theory of information.

Shannon was concerned with a practical engineering problem.

How can messages be transmitted reliably and efficiently through communication channels?

Imagine speaking over a noisy telephone connection.

Your words are converted into electrical signals.

Those signals travel through a communication system.

At the receiving end, they are reconstructed.

But noise may interfere with the transmission.

Some information may be distorted or lost.

Engineers need ways to understand how much information a message contains, how effectively it can be represented and how reliably it can be transmitted.

Shannon developed a mathematical framework for studying these questions.

His achievement was profound because it separated the technical problem of communication from the meaning of individual messages.

### Information without interpretation

Suppose a transmitter sends one of two possible symbols:

`0` or `1`

If both are equally likely, learning which one was sent removes one bit of uncertainty.

If the transmitter always sends `0`, receiving another `0` tells us nothing unexpected.

The symbols are identical in appearance to those used in ordinary binary representation.

But their informational significance depends on the probabilities of possible outcomes.

A message that is entirely predictable carries little new information in Shannon's statistical sense.

A less predictable message can carry more.

This does not mean that a surprising statement is necessarily valuable, truthful or meaningful.

It means that learning the outcome reduces more uncertainty.

Shannon's theory concerns communication and statistical structure.

It does not, by itself, explain semantics.

That distinction is one of the most important ideas in the history of computing.

## 9. Measuring Uncertainty

Imagine a coin that can land heads or tails.

If it is fair, the two outcomes are equally likely.

Before the toss, we have uncertainty about the result.

After observing it, that uncertainty disappears.

Shannon quantified this kind of uncertainty using a mathematical measure called entropy.

For a discrete set of possible outcomes:

H = −Σᵢ pᵢ log₂(pᵢ)

Here, pᵢ is the probability of outcome i.

The logarithm is base two, so the result is measured in bits.

This equation may look intimidating, but its underlying idea is straightforward.

More uncertainty generally means more information is required to specify an outcome.

### A fair coin

For heads and tails:

p(heads) = 0.5; p(tails) = 0.5

The entropy is:

H = −0.5 log₂(0.5) − 0.5 log₂(0.5)

Since log₂(0.5) = −1:

H = 1 bit

### A predictable coin

Now imagine a coin that lands heads 90% of the time.

p(heads) = 0.9; p(tails) = 0.1

Its entropy is approximately:

H ≈ 0.469 bits

The result is less uncertain because heads is much more likely.

Notice that the outcome tails is individually surprising.

If tails occurs, it provides more information about that particular outcome than an observation of heads would.

But the average uncertainty of the source is lower than for a fair coin.

That is the distinction between the surprise of a particular event and the average entropy of the system producing events.

### The literary connection

Consider these two sequences:

`AAAAAAAAAAAA`

`QJXMPZKWRVTA`

If we treat them as samples and examine the variety and distribution of their characters, the second appears less predictable.

But the second sequence is not automatically more meaningful.

The first might be a deliberate signal.

The second might be random letters.

Or the second could be an encrypted message.

Shannon entropy concerns statistical uncertainty, not human significance.

Information and meaning are connected in communication, but they are not identical concepts.

## 10. Why Language Can Be Compressed

Natural language contains redundancy.

We often predict what words or letters are likely to come next.

Consider:

The detective opened the locked...

You might expect door.

Or perhaps box, cabinet or drawer.

Some completions are more plausible than others.

This predictability means that natural language contains statistical regularities.

A compression algorithm can exploit such regularities to reduce the number of bits needed to represent information.

For example, if a symbol occurs frequently, some encoding schemes can assign it a shorter representation.

Less common symbols can receive longer representations.

This is the principle behind Huffman coding, introduced by David Huffman in 1952.

Other compression methods use different techniques, including dictionaries of repeated patterns and increasingly sophisticated statistical models.

Compression is not necessarily encryption.

A compressed file may look unfamiliar to someone inspecting its bytes, but that does not mean its contents are secure.

With a lossless compression format and the required decoding information, the original data can be reconstructed exactly. Lossy compression deliberately discards some information.

### Redundancy is not always waste

In literature, repetition can be aesthetically important.

A repeated phrase may establish rhythm.

A recurring image may connect different scenes.

An apparently unnecessary sentence may create atmosphere or reinforce a theme.

From an information-theoretic perspective, predictable repetition can lower statistical uncertainty.

But from a literary perspective, repetition may increase significance.

This is another example of the difference between measuring information and interpreting meaning.

An algorithm designed to minimise the number of stored bits may remove representational redundancy.

A novelist may deliberately create repetition because it makes the text more powerful.

The two activities optimise different things.

### Predictive text and language models

Modern language models also exploit statistical relationships in language, although their mechanisms are much more elaborate than simple letter-frequency tables.

They learn patterns from large quantities of training material and use those patterns to generate or evaluate sequences of tokens.

A token may represent a word, part of a word or another textual unit.

The connection with Shannon's work is important, but it should not be exaggerated.

Information theory provides mathematical tools for analysing uncertainty, coding and prediction.

It does not fully explain the reasoning capabilities, behaviour or internal representations of modern language models.

Nor does a model's ability to predict or generate text automatically establish human-like understanding.

Still, a historical connection is visible.

Poe's Legrand used the statistical structure of language to recover hidden text.

Modern computational systems use far more complex statistical structures to process and generate language.

The underlying observation remains: language is patterned rather than random.

## 11. A Cipher Is Not a Secret Forever

We can now return to the mystery that opened the chapter.

Why was the concealed message vulnerable?

Because its creator used a transformation that preserved too much information about the underlying language.

Every letter was consistently replaced.

Repeated patterns survived.

The reader could exploit those patterns to reconstruct the original message.

A secure encryption system must resist much more sophisticated attempts at analysis.

Modern cryptography uses carefully designed mathematical algorithms and secret keys.

It aims to protect information against adversaries who may know the encryption algorithm and possess extensive computational resources.

The secrecy of a sound modern system should not depend on nobody knowing how the algorithm works.

Instead, its security should depend upon protecting the appropriate secret key and using the system correctly.

The idea is that a cryptographic system should remain secure even if its design is known to an adversary, provided the secret key remains protected.

A modern cryptographic system is therefore fundamentally different from the Caesar cipher.

With a Caesar cipher, there are only 26 possible alphabetic shifts, including the unchanged alphabet.

An attacker can test them all immediately.

A strong modern cipher may use a key space so large that exhaustive search is computationally infeasible under realistic assumptions.

For example, a uniformly random 128-bit key has:

2¹²⁸

possible values.

That is approximately:

3.4 × 10³⁸

possibilities.

However, key length alone does not guarantee security.

The algorithm, mode of operation, key generation, implementation and surrounding system all matter.

A poorly implemented encryption system can fail even when it uses a strong underlying algorithm.

### What cryptography protects

Modern information security distinguishes several objectives.

Confidentiality prevents unauthorised disclosure.

Integrity protects against unauthorised modification.

Authentication helps establish the identity or origin of communicating parties or messages.

Availability concerns keeping systems and information accessible when needed.

Encryption primarily serves confidentiality, while cryptographic authentication and integrity mechanisms address related but distinct problems.

These concepts will become increasingly important as literature begins incorporating actual computer programs.

A program can contain secrets, reveal them, verify them or conceal them.

And a fictional message can become not merely something to read, but something to execute.

## 12. The Difference Between Information and Meaning

We began with a message that nobody could understand.

We then discovered how its letters might be disguised, represented numerically and analysed mathematically.

But there is one final problem.

Suppose we receive the following message:

`THE DOOR IS OPEN`

We can count its characters.

We can encode it in UTF-8.

We can encrypt it.

We can measure statistical properties of the sequence.

We can transmit it reliably across a network.

But what does it mean?

That depends on context.

The door might be the entrance to a room.

It might be a metaphor for opportunity.

It might be a password phrase.

It might be a line from a play.

Or it might be a deliberate attempt to deceive someone.

No calculation of the message's Shannon entropy can determine its intended meaning without additional assumptions and contextual information.

The meaning is not simply identical to the statistical properties of the characters.

It emerges through relationships among language, context, interpretation and the world.

This distinction brings us back to the literary machine imagined by Jonathan Swift.

His professor could rearrange words mechanically.

Poe's Legrand could recover a hidden message by analysing symbols.

Shannon could measure the uncertainty associated with possible messages.

Modern computers can encode, transmit, search, encrypt and generate enormous quantities of text.

Yet the existence of a formal representation does not eliminate the need for interpretation.

The same sentence may be meaningful in one context and absurd in another.

The same symbols may be random noise to one reader and a secret message to someone possessing the right key.

And a text can be perfectly preserved at the level of bytes while its cultural significance changes dramatically over time.

This is why literature and information theory make such an interesting pair.

Information theory tells us how to measure and communicate structured uncertainty.

Literature investigates what human beings do with messages once they encounter them.

The two disciplines ask different questions about the same material.

### The secret language revealed

The greatest insight of this chapter is not that every mystery can be solved with mathematics.

It is that written language has several layers.

At one level, it consists of physical marks or signals.

At another, those marks represent characters and words.

At another, they may be transformed or concealed.

And at another, they acquire meaning through interpretation.

A computer can manipulate the lower layers with extraordinary precision.

But manipulating representations and understanding significance remain distinct challenges.

This distinction prepares us for the next stage of our investigation.

So far, our programs have encoded messages, counted symbols and transformed text.

But what happens when the symbols are not merely data?

What happens when they are instructions?

A computer program is a kind of writing that can cause actions to occur.

It can change information, produce images, make decisions and respond to its environment.

Its words do not merely describe a possible world.

They can help construct one.

That is where literature and programming begin to converge in a much stranger way.

## Questions to Take Away

1. Why can a substitution cipher preserve enough information about language to make frequency analysis possible?
2. In The Gold-Bug, what is the difference between recovering the words of the message and understanding how to use its instructions?
3. Are the dancing figures in Conan Doyle's story primarily an encryption system, a form of disguise or both?
4. Why is representing a message in binary not equivalent to encrypting it?
5. If a random sequence has high Shannon entropy, does that make it a valuable or meaningful piece of writing?
6. Why might a highly predictable phrase carry great emotional significance despite having relatively little statistical uncertainty?
7. Can a computer process language successfully without understanding the meaning of the words in a human sense?
8. How might a novelist use the difference between code, encryption and meaning to create a mystery?

## A Small Experiment: Break the Secret Message

You have intercepted the following ciphertext:

`WKH PHHWLQJ LV DW QRRQ`

You know that it was encrypted using a Caesar cipher, but you do not initially know the shift.

### Step 1: Examine the symbols

The ciphertext contains five groups.

The first group is three letters long.

Some letters repeat.

The character W appears several times.

These observations may help, but for a Caesar cipher there is an even simpler approach: test possible shifts.

### Step 2: Try shifting backwards

Begin with a shift of one.

W becomes V.

K becomes J.

H becomes G.

The first word becomes:

`VJG`

That does not appear to be an English word.

Now try shifting backwards by two positions:

`UIF`

Still not a likely English word.

Try shifting backwards by three:

`THE`

This is promising.

### Step 3: Decode the complete message

Apply the same shift of three to every letter, wrapping backwards around the alphabet where necessary.

| Ciphertext | Decoded text |
| --- | --- |
| WKH | THE |
| PHHWLQJ | MEETING |
| LV | IS |
| DW | AT |
| QRRQ | NOON |

The recovered message is:

THE MEETING IS AT NOON

Every transformation is consistent with the same Caesar shift.

### Step 4: Verify the result with Python

```python
ciphertext = "WKH PHHWLQJ LV DW QRRQ"


decoded = ""


for char in ciphertext:
    if "A" <= char <= "Z":
        n = ord(char) - ord("A")
        decoded += chr((n - 3) % 26 + ord("A"))
    else:
        decoded += char


print(decoded)
```

Expected output:

```text
THE MEETING IS AT NOON
```

The program converts each uppercase letter to its position in the alphabet, subtracts three, wraps around using modulo 26 and converts the result back into a character.

Spaces are preserved unchanged.

### Step 5: Investigate uncertainty

Now imagine that you are given a longer ciphertext without knowing its language or encryption method.

Would the same approach work?

Not necessarily.

A Caesar cipher has very few possible shifts, so exhaustive testing is easy.

A general substitution cipher has:

26!

possible letter permutations, approximately 4.03 × 10²⁶.

Yet its statistical structure still provides clues.

This is why frequency analysis becomes useful.

### The deeper question

Now suppose you discover that the message was not intended to arrange a meeting at all.

It was a phrase used in a fictional play.

You have successfully decrypted the characters, but misunderstood their significance.

Cryptanalysis recovered the text. Interpretation was still required to understand the message.

The experiment demonstrates why recovering information and understanding meaning are different achievements.

## Further Reading

### Literature and Primary Texts

Edgar Allan Poe — The Gold-Bug (1843)

The original cryptographic detective story, including the explanation of Legrand's frequency analysis.

[Edgar Allan Poe Society of Baltimore — Historical and comparative texts](https://www.eapoe.org/works/info/pt042.htm)

[The Gold-Bug — 1845 text](https://www.eapoe.org/works/tales/goldbgb.htm)

Arthur Conan Doyle — The Adventure of the Dancing Men (1903)

A Sherlock Holmes story in which substitution cryptography and visual symbolism become central to a criminal investigation.

[Project Gutenberg — The Return of Sherlock Holmes](https://www.gutenberg.org/files/108/108-h/108-h.htm)

### Computing and Information Theory

Claude E. Shannon — A Mathematical Theory of Communication (1948)

The foundational paper establishing a mathematical framework for information, entropy, coding and reliable communication.

[Bell Labs / Bell System Technical Journal — Part I](https://doi.org/10.1002/j.1538-7305.1948.tb01338.x)

[Bell Labs / Bell System Technical Journal — Part II](https://doi.org/10.1002/j.1538-7305.1948.tb00917.x)

[Complete paper — Yale-hosted PDF](https://www.cs.yale.edu/homes/yry/readings/general/shannon1948.pdf)

Computer History Museum — ASCII (1963)

Historical explanation of the development of a standardised character encoding system.

[Computer History Museum — Timeline of Computer History, 1963](https://www.computerhistory.org/timeline/1963/)

Unicode Consortium — The Unicode Standard

The official technical reference for Unicode characters, code points and text encoding.

[Unicode Consortium — Official standard](https://www.unicode.org/standard/standard.html)

### Suggested Reading Order

Read Poe first, observing how Legrand identifies patterns in concealed language.

Then read Doyle, noting how the same underlying method becomes part of a more elaborate detective mystery.

Next, examine ASCII and Unicode to understand why representing characters is not the same as encrypting them.

Finally, approach Shannon's paper. Its mathematics is more demanding, but the central idea is accessible: information theory measures uncertainty associated with possible messages, independently of the meanings readers may assign to them.

Together, these sources trace a movement from literary puzzle-solving to the mathematical treatment of information.

## Up Next — The Programmer as Author

Why Computer Programs Resemble Stories

We have discovered that language can be represented as information.

Letters can become numbers.

Messages can be disguised, transmitted, compressed and reconstructed.

But the next step is much stranger.

A computer program is a text that specifies operations.

Its statements can create objects, change conditions, select alternatives and produce consequences.

A novelist invents characters and events.

A programmer defines objects, states and rules.

Both construct systems in which one event may cause another.

In Chapter Six, we will explore the relationship between storytelling and software engineering.

We will examine sequence, choice, repetition, state, causation and the structure of computational worlds.

We will ask why a program can resemble a plot, why debugging can resemble detective work and how the rules of a fictional world can become executable instructions.

The central question is deceptively simple.

If a story describes what happens, and a program describes what can happen, how far apart are literature and software?

