Encrypted Messages: Mathematical Games in Literature

#Pure tech

12.04.2024 Reading time: 7 minutes

Marta Macho Stadler

Ilustration: Laura Arrue

Mathematics is highly present in our daily lives. In the technological field, among other uses, it underpins the cryptographic codes that many digital tools rely on. Literature also hasn’t forgotten mathematics. Shall we combine cryptography and literature?

PLAYING AND CODING: GETTING STARTED

Today, cryptography is taught in many undergraduate and graduate university programs. Courses that include this discipline, study theoretical tools that enable information to be transmitted reliably and securely.

Encrypted messages are used in diverse fields such as espionage or commercial transactions. They also present an extraordinary intellectual challenge for anyone who wants to "play" with them. Literature contains wonderful examples of coded messages that structure the plots of certain stories. Here are two examples.

THE ADVENTURE OF THE DANCING MEN: A CRYPTOGRAM IN A MYSTERY STORY

Sherlock Holmes, the famous detective created by Arthur Conan Doyle (1859–1930), was known for his great deductive skills. He had a "mathematical mind." In his short story The Adventure of the Dancing Men, the detective also uses his cryptographic skills.

In this story, Hilton Cubitt seeks Holmes’ help to unravel a mystery involving his wife: Elsie is distressed after receiving strange messages. These contain no words, only stick figures with arms and legs positioned in various ways, some carrying flags and, at times, even turned upside down. Holmes explains:

These hieroglyphics have evidently a meaning. If it is a purely arbitrary one it may be impossible for us to solve it. If, on the other hand, it is systematic, I have no doubt that we shall get to the bottom of it.

Holmes begins his investigation by studying the frequency of each symbol (each stick figure) in the messages Elsie receives and compares it with the frequency of letter usage in English.

Having once recognised, however, that the symbols stood for letters, and having applied the rules which guide us in all forms of secret writings, the solution was easy enough.

The detective starts by identifying the most repeated symbol, which must correspond to the letter E, the most common letter in English texts. Guided by context, grammar, and common sense, Holmes decodes the hidden meaning of the cryptograms.

In fact, this "alphabet" of "dancing men" was an invention of Patrick, Elsie's father and leader of a gang of criminals. This way of writing allowed him to send warnings to his gang. Because they looked like a silly game, these messages went unnoticed by anyone who didn’t know the key.

Despite uncovering the code, Holmes fails to prevent the murder of his client, Hilton Cubitt, although he does unmask the killer. Already familiar with the hidden code, he sends a message in the "dancing men" alphabet, pretending it comes from Elsie…

THE GIANT RAFT: A CRYPTOGRAM IN AN ADVENTURE NOVEL

The Giant Raft. Eight Hundred Leagues on the Amazon is an adventure and suspense novel by Jules Verne (1828–1905).

The story takes place in 1852. Joam Garral, a man of Brazilian origin, owns a prosperous estate in Iquitos (Peru). He is the father of Benito and Minha. His daughter is about to marry Benito's best friend, Manuel Valdez, in Belém (Brazil). Garral decides to transport the family entourage and servants aboard a large raft heading for the Atlantic coast of Brazil, down the Amazon River. They must travel eight hundred leagues along the river to celebrate the wedding.

But Garral has a secret: he is a fugitive from Brazilian justice. Years ago, he was falsely accused of theft and murder. He had to flee Brazil to avoid an unjust punishment: a death sentence for a crime he didn‘t commit. Upon reaching Manaus, Torres, a sinister character, blackmails Garral, demanding that he marry Minha in exchange for his silence. Garral refuses to submit, is arrested, and sentenced to death.

However, Torres possesses a coded document with the confession of the real murderer. This manuscript uses the so-called "Gronsfeld cipher," which is more complex than the code Conan Doyle uses in The Adventure of the Dancing Men. While Doyle’s story uses a substitution cipher where each character in the original text is replaced by another in the coded text, the cipher in The Giant Raft is polyalphabetic: each symbol does not always correspond to the same character. Moreover, it uses a numerical key to encode and decode. Here’s an example. Let's first fix an original 26-letter alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

Let’s suppose the message we want to send is:

BIZKAIATECH MAGAZINE

With the key 12345, the encrypted message would be:

CKCOFJCWIHI ODKFAKQI

How is this obtained? The key (one digit per letter) is placed under the text to be encrypted and repeated as many times as necessary. The encrypted message is produced by replacing each original letter with the letter located (to the right in the fixed alphabet) by as many positions as indicated by the digit below that letter:

B I Z K A I A T E C H M A G A Z I N E

1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4

C K C O F J C W I H I O D K F A K Q I

As you can see in the chart, B+1=C, I+2=K, Z+3=C and so on. To decrypt the message, simply reverse the process: in the coded message, each letter is replaced by the one located (to the left in the alphabet) by as many positions as the digit below that letter: C - 1 = B, K - 2 = I, C - 3 = Z, etc.

The Giant Raft begins with a coded message—the final paragraph of a hundred-line encrypted text (not included in the novel) hiding the confession of a man named Ortega, the true culprit of the crime for which Garral was accused.

P h y j s l y d d q f d z x g a s g z z q q e h x g k f n d r x u j u g i o c y t d x v k s b x h h u y p o h d v y r y m h u h p u y d k j o x p h e t o z s l e t n p m v f f o v p d p a j x h y y n o j y g g a y m e q y n f u q l n m v l y f g s u z m q i z t l b q g y u g s q e u b v n r c r e d g r u zb l r m x y u h q h p z d r r g c r o he p q x u f i v v r p l p h o n t h v d d q f h q s n t z h h h n f e p m q k y u u e x k t o g z g k y u u m f v i j d q d p z j q s y k r p l x h x q r y m v k l o h h h o t oz v d k s p p s u v j h d.

When Garral is arrested in Manaus, Judge Jarríquez, responsible for his defense, tries to decode the message using various methods. His efforts are unsuccessful. Almost at the last moment, the name "Ortega" is suggested as the possible signatory of the encrypted message. Thanks to this discovery, the judge finds the key and uses the Gronsfeld method (although he does not name it, only describes it) to decipher the hidden message:

The real author of the robbery of the diamonds and of the murder of the soldiers who escorted the convoy, committed during the night of the twenty- second of January, one thousand eight hundred and twenty-six, was thus not Joam Dacosta, unjustly condemned to death; it was I, the wretched servant of the Administration of the diamond district; yes, I alone, who sign this with my true name, Ortega.

Thanks to this revelation, Garral (whose real surname was Dacosta) escapes the gallows, and the story ends happily.

USING TECHNOLOGY TO ENCODE AND DECODE

There are many online sites that help encode and decode messages using different encryption systems. My favorite is the website DCode.fr, where I’ve tested the Gronsfeld method with different alphabets and keys. However, it’s always more fun to do it manually, as long as the message to be encoded isn’t too long…

Labels

  • #cultura
  • #ciencia
  • #educación
  • #mujeres

Take our advice and check it out

Slide to show more