Mary Queen of Scots, the controversial 16th century royal figure, met a rather (spoiler alert) grisly end.

And it all had to do with a cracked code.

But how did Mary actually send her secret messages—the ones that she ultimately lost her head over?

Mary communicated using a cipher that she changed repeatedly, substituting letters for different symbols and essentially creating a new alphabet that could be deciphered by anyone who had the code.

She wrote letters communicating with Catholic allies (England wasn’t too happy with the fact that she was a Protestant) and would hide them in a hollowed out bung inside beer barrels that could be smuggled to the receiver.

But in 1586, Mary was found out and entrapped by people who believed she wanted to have Queen Elizabeth I killed (Mary would have taken the throne if that had happened) after her code was broken.

The text above is a summary, you can read full article here.