Encryption, decryption, and cracking (article) | Khan Academy (2024)

One of the earliest encryption techniques is the Caesar Cipher, invented by Julius Caesar more than two thousand years ago to communicate messages to his allies.

The Caesar Cipher is a great introduction to encryption, decryption, and code cracking, thanks to its simplicity.

Encrypting a message

Imagine Caesar wants to send this message:

SECRET MEETING AT THE PALACE

Here's what that might look like encrypted:

YKIXKZ SKKZOTM GZ ZNK VGRGIK

That looks an awfully lot like gobbledygook at first, but this encrypted message is actually very related to the original text.

The Caesar Cipher is a simple substitution cipher which replaces each original letter with a different letter in the alphabet by shifting the alphabet by a certain amount.

To make the encrypted message above, I shifted the alphabet by 6 and used this substitution table:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
GHIJKLMNOPQRSTUVWXYZABCDEF

S shifts 6 letters over to Y, E shifts 6 letters over to K, etc. Here's the first word and its shifts:

SECRET
YKIXKZ

Check your understanding

Now imagine Caesar wants to send the following message, with the same shift of 6:

ALEXANDRIA SOON

What would be the encrypted message?

Choose 1 answer:

Choose 1 answer:

Decrypting a message

According to historical records, Caesar always used a shift of 3. As long as his message recipient knew the shift amount, it was trivial for them to decode the message.

Imagine Caesar sends this message to a comrade:

EHZDUH EUXWXV

The comrade uses this substitution table, where the alphabet is shifted by 3:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC

They can then decode the message with certainty. The first letter "E" was shifted by 3 from "B", the second letter "H" was shifted by 3 from "E", etc. The result is this ominous message:

BEWARE BRUTUS

Check your understanding

Here's another message Caesar might send:

FURVV WKH UXELFRQ

Assuming Caesar's usual shift of 3, what does that decrypt to?

Choose 1 answer:

Choose 1 answer:

Cracking the cipher

Imagine that a very literate and savvy enemy intercepts one of Caesar's messages.

RZ VMZ WMDIBDIB VGG AJMXZN OJ EJDI RDOC XGZJKVOMV OJ YZAZVO OCZ ZIZHT LPZZI VO OCZ IDGZ YZGOV

That enemy does not know that Caesar always uses a shift of 3, so he must attempt to "crack" the cipher without knowing the shift.

There are three main techniques he could use: frequency analysis, known plaintext, and brute force.

Frequency analysis

Human languages tend to use some letters more than others. For example, "E" is the most popular letter in the English language. We can analyze the frequency of the characters in the message and identify the most likely "E" and narrow down the possible shift amounts based on that.

Try it out yourself! Paste the message in the text area below and analyze the frequency graph to identify a possible "E":

Known plaintext

Another term for the original unencrypted message is plaintext. If the enemy already knew some part of the plaintext, it will be easier for them to crack the rest of the encrypted version.

For example, messages tend to start with similar beginnings. In WWII, encrypted German messages always started with a weather forecast, which ultimately made them easier for British mathematician Alan Turing to crack.

Do you think Julius started this message in a common way?

Brute force

There are only 25 possible shifts (not 26 — why not?). The enemy could take some time to try out each of them and find one that yielded a sensible message. They wouldn't even need to try the shifts on the entire message, just the first word or two.

Try it yourself below:

Caesar's enemy wouldn't have a computer to help them, but it likely would take them less than an hour if they understood the idea of the Caesar Cipher.

Have you managed to crack the code and decrypt the message?Click below for the big reveal!

According to the frequency analysis, the most common encrypted letter was "Z", so that was most likely to originally be "E". Indeed, this message was shifted by 21, and "Z" corresponds to "E".

Here's the message:

WE ARE BRINGING ALL FORCES TO JOIN WITH CLEOPATRA TO DEFEAT THE ENEMY QUEEN AT THE NILE DELTA

Encryption, decryption, and cracking

Thanks to this exploration of the Caesar Cipher, we now understand the three key aspects of data encryption:

  • Encryption: scrambling the data according to a secret key (in this case, the alphabet shift).
  • Decryption: recovering the original data from scrambled data by using the secret key.
  • Code cracking: uncovering the original data without knowing the secret, by using a variety of clever techniques.

Whenever we consider a possible encryption technique, we need to think about all those aspects: how easy is it to encrypt? how easy is it to decrypt? And most importantly, how easy is it for a nefarious individual to crack the code?

We can no longer use the Caesar Cipher to secure our data, as it is far too easy to crack, but understanding the Cipher prepares us for understanding modern encryption techniques.

If you'd like, you can dive deeper into the Caesar Cipher in our Khan Academy tutorial on Ancient Cryptography.

  1. Heidi New & Tim Bell. Coding - Encryption. Retrieved from: http://csfieldguide.org.nz/en/chapters/coding-encryption.html
  2. Caesar Cipher. (2018, November 7). Retrieved December 3, 2018 from Wikipedia: https://en.wikipedia.org/wiki/Caesar_cipher

🙋🏽🙋🏻‍♀️🙋🏿‍♂️Do you have any questions about this topic? We'd love to answer—just ask in the questions area below!

If you don't see a "Questions" area below, you're either using the mobile app or reading this article in a pop-up. If you're on the mobile app, visit this article from a browser. If you're in a pop-up, click the article title at the top.

Encryption, decryption, and cracking (article) | Khan Academy (2024)

References

Top Articles
Latest Posts
Article information

Author: Aracelis Kilback

Last Updated:

Views: 6324

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Aracelis Kilback

Birthday: 1994-11-22

Address: Apt. 895 30151 Green Plain, Lake Mariela, RI 98141

Phone: +5992291857476

Job: Legal Officer

Hobby: LARPing, role-playing games, Slacklining, Reading, Inline skating, Brazilian jiu-jitsu, Dance

Introduction: My name is Aracelis Kilback, I am a nice, gentle, agreeable, joyous, attractive, combative, gifted person who loves writing and wants to share my knowledge and understanding with you.