For those of you who have only seen the Leonardo DiCaprio movie, the Man in the Iron Mask was an actual historical figure. He was a mysterious prisoner in the time of Louis XIV. Two centuries later, a cryptoanalyst finally discovered his probable identity.
In 1698, the Man in the Iron Mask had gained quite a reputation for himself (some said herself) when he had been in a prison in Savoy. In Paris, he was the subject of so much gossip that he became a legend for centuries to come. Theorists tried to work out his identity. Some, most famously, Alexandre Dumas, made up an identity, and spun a tale in which the Man in the Iron Mask was the secret twin of Louis XIV. Twins were a threat to orderly succession, but no one could kill a prince of royal blood, so the second twin was masked and imprisoned.
For two centuries, the mystery remained. There were clues, but they were written in what's known as The Great Cipher. This numeric code kept all the court communications secret. In 1890, a French military cryptoanalyst named Etienne Bazeries decided to try his hand at The Great Cipher. There were about 600 different numbers used in cipher messages, so the numbers couldn't match up to letters of the alphabet. On the other hand, Bazeries realized, there are 676 ways of pairing up letters of the alphabet. The Great Cipher must use numbers as substitutes for pairs of letters — with a few for more common words, and a few left out because certain letters are never paired up. By making guesses at frequently-used pairs of letters, he got a few words, then used those deciphered numbers to guess at yet more words, and find more numbers. Eventually, the code was cracked.
Bazeries began working his way through correspondence from Louis XIV to his minister of war and found a letter about a certain Vivien de Bulonde. Bulonde was a military man, and was put in charge of an attack on the Italian border. As soon as he heard Austrian troops might be closing in on his position, he turned tail and ran, leaving his own wounded soldiers behind. Louis ordered the minister to put him in the prison at Savoy, but allowed that he would be "permitted to walk the battlements during the day with a mask."
So Louix XIV secret twin was actually just a cowardly officer. Reality might be more accurate than fiction, but it's far less juicy.
[Via The Code Book]