Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The Caesar cipher encrypts a message by shifting every letter the same number of places through the alphabet. To decrypt it, shift each letter back by that amount. For example, with a shift of 3, HELLO becomes KHOOR and decrypts back to HELLO. The method is easy to demonstrate, but it is not secure for protecting private information.

What is a Caesar cipher?

A Caesar cipher is a substitution cipher: each plaintext letter is replaced by a different letter a fixed number of positions later in the alphabet. That agreed number is the shift, or key. With a shift of 3, A becomes D, B becomes E, and the pattern continues through the alphabet. After Z, it wraps around to A. Khan Academy’s lesson and the U.S. Naval Academy’s frequency-analysis lesson describe this fixed-shift substitution.

For a standard 26-letter English alphabet, number the letters from A=0 to Z=25. If P is a plaintext letter and k is the shift, encryption is C = (P + k) mod 26. Decryption is P = (C − k) mod 26. “Mod 26” makes the count wrap back to the beginning of the alphabet when it passes Z.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to encrypt and decrypt a message

Encrypt with a shift of 3

Move each letter three places forward. For letters near the end of the alphabet, continue from A after Z.

Plaintext Shifted letter
H K
E H
L O
L O
O R

The ciphertext is KHOOR.

Decrypt with the same shift

Move each ciphertext letter three places backward: K→H, H→E, O→L, O→L, and R→O. The recovered plaintext is HELLO. In a basic demonstration, keep spaces and punctuation unchanged; the shift applies to letters.

How the Caesar cipher is broken

Brute force: try every shift

There are 25 nontrivial shifts in the standard 26-letter alphabet; shifting by 0 leaves the text unchanged. A person or program can test each possible shift and look for readable output. This takes little language knowledge, though the solver still needs to recognize which result makes sense. Khan Academy’s overview of encryption, decryption, and code cracking discusses brute-force attacks.

Frequency analysis: look for language patterns

A fixed substitution changes which letters appear, but it does not change how often each plaintext letter occurs. A codebreaker can count ciphertext letters and compare their pattern with the expected pattern for the language being used. This approach becomes more persuasive with longer text; a short or unusual message may not provide enough evidence. The Naval Academy lesson demonstrates frequency counting, and Khan Academy also describes frequency analysis as a way to crack substitution ciphers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Brute force is practical because the set of shifts is so small and does not require a known word or a detailed language model. Frequency analysis uses language patterns and can help identify a shift when there is more ciphertext to examine. Neither method requires advanced computing for this cipher.

Is the Caesar cipher secure?

No. Its small set of possible shifts makes exhaustive guessing easy, while its preserved letter-frequency pattern gives a second route to solving it. Do not use a Caesar cipher to protect passwords, personal messages, financial details, or other sensitive information. Its value is educational: it makes substitution, keys, wraparound, encryption, decryption, and basic cryptanalysis visible in a simple example.

What is its historical connection?

The cipher is traditionally associated with Julius Caesar, and Khan Academy’s lesson recounts that Al-Kindi used frequency analysis to break it. That account supports the broad historical attribution, but it does not establish a precise date or verify a particular surviving message.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to demonstrate the shift visually

A cipher wheel or disk can make the alphabet rotation easy to see in a classroom. It is optional: two alphabet strips, with one shifted by the chosen key, or a few handwritten letter mappings show the same operation. CaesarCipher.org’s educational guide describes a cipher-wheel teaching aid; this does not establish retail availability for any particular product.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.