keepcalculator

06 Numbers and Powers

Caesar Cipher Shift: What ‘a’ Becomes

Card No. 06·40243 · Updated · Standard formula, shown below

The calculator on this card is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

Under a Caesar cipher shift, the letter a becomes the letter that is that many positions later in the alphabet. For a shift of 1, a becomes b; for a shift of 3, a becomes d; for a shift of 25, a becomes z. In short, the result depends entirely on the shift value you choose.

Formula

The Caesar cipher is a substitution cipher where each letter in the plaintext is replaced by a letter a fixed number of positions down the alphabet. The encryption formula for a single letter is:

E(x) = (x + shift) mod 26

Where:

  • x = the position of the plaintext letter (0 for a, 1 for b, …, 25 for z)
  • shift = the number of positions to move forward (an integer from 0 to 25)
  • E(x) = the position of the ciphertext letter (0 for a, 1 for b, …, 25 for z)

The mod operation (modulo) wraps around the alphabet, so a shift past z returns to a. For example, shifting z by 3 gives: (25 + 3) mod 26 = 28 mod 26 = 2, which is c.

Worked Example

Using the default shift of 3 (the classic Caesar cipher used by Julius Caesar):

  1. Take the letter a. Its position is 0 (since a = 0, b = 1, …, z = 25).
  2. Add the shift: 0 + 3 = 3.
  3. Apply modulo 26: 3 mod 26 = 3.
  4. Convert back to a letter: position 3 is d.

So with a shift of 3, a becomes d. The calculator above gives the same result: enter 3 and you get d.

How the Caesar Cipher Works

The Caesar cipher is one of the oldest known encryption techniques, named after Julius Caesar, who reportedly used it to communicate with his generals. It is a type of substitution cipher where each letter in the plaintext is replaced by a letter a fixed number of positions down the alphabet. The same shift is applied to every letter, making it a monoalphabetic substitution.

To encrypt a message, you take each letter, find its position (A=0, B=1, …, Z=25), add the shift, and take the result modulo 26. To decrypt, you subtract the shift instead. For example, with a shift of 3, the word “hello� becomes “khoor�.

The cipher is symmetric: the same key (the shift value) is used for both encryption and decryption. This simplicity made it easy to use in ancient times, but also makes it trivially easy to break today.

How to Choose a Shift Value

Any integer from 0 to 25 is a valid shift for a Caesar cipher. A shift of 0 leaves the text unchanged, and a shift of 26 is the same as a shift of 0 because the alphabet wraps around. In practice, shifts of 1 to 25 are used, with 3 being the most famous due to Caesar himself.

There is no “best� shift; the security is the same regardless of the value, because an attacker can simply try all 25 possible shifts. However, some shifts produce more recognizable patterns. For instance, a shift of 13 is special because it is its own inverse: encrypting twice returns the original text. This is known as ROT13 and is often used in online forums to hide spoilers.

When choosing a shift, consider that the result must be a letter. If you want to encrypt numbers or punctuation, you would need an extended alphabet, but the classic Caesar cipher only handles letters.

Common Problems and Misconceptions

One common mistake is forgetting that the alphabet wraps around. For example, shifting z by 1 gives a, not something else. The modulo operation handles this correctly.

Another issue is mixing up the direction. Encryption shifts forward (a→b with shift 1), while decryption shifts backward (b→a with shift 1). If you use the wrong direction, you get gibberish.

A frequent misconception is that the Caesar cipher is secure. In reality, it is one of the weakest ciphers because there are only 25 possible keys. A brute-force attack that tries all shifts will succeed in seconds, and even without a computer, a person can break it by trying a few shifts or by frequency analysis.

Also, note that the cipher is case-sensitive in some implementations. The formula above works for uppercase letters; for lowercase, you would use the same positions but with lowercase output. Most simple implementations treat both cases the same.

Comparison with Other Ciphers

The Caesar cipher is a special case of the affine cipher, which uses a formula like E(x) = (ax + b) mod 26, where a and b are constants. The Caesar cipher is the affine cipher with a = 1. The affine cipher offers more keys (312 possible combinations) but is still easily broken.

Another related cipher is the Vigenère cipher, which uses a keyword to apply different shifts to different letters. This makes it a polyalphabetic substitution, which is much harder to break than the monoalphabetic Caesar cipher.

Compared to modern encryption like AES, the Caesar cipher is trivial. It provides no real security and is used mainly for educational purposes or to obscure text casually.

Safety and Limitations

The Caesar cipher offers no security against determined attackers. It is not suitable for protecting sensitive data. If you need to encrypt information, use a modern, well-vetted encryption algorithm like AES, and follow best practices for key management.

Even for casual use, remember that the cipher is reversible by anyone who knows the shift, and the shift can be guessed easily. Do not use it for passwords, personal messages, or anything you would not want others to read.

Frequently Asked Questions

What does ‘a’ become with a shift of 1?

With a shift of 1, a becomes b. The position of a is 0, plus 1 equals 1, which is b.

What does ‘a’ become with a shift of 25?

With a shift of 25, a becomes z. The position of a is 0, plus 25 equals 25, which is z.

What does ‘z’ become with a shift of 3?

With a shift of 3, z becomes c. The position of z is 25, plus 3 equals 28, modulo 26 equals 2, which is c.

How do I decrypt a Caesar cipher?

To decrypt, subtract the shift from each letter’s position. For example, if you have d and the shift is 3, subtract 3 to get 0, which is a.

Is ROT13 the same as a Caesar cipher?

Yes, ROT13 is a Caesar cipher with a shift of 13. Because 13 is half of 26, applying it twice returns the original text, so it is its own inverse.

Can I use a shift larger than 25?

Yes, but the effective shift is the value modulo 26. For example, a shift of 29 is the same as a shift of 3, because 29 mod 26 = 3.

Related

Formula used
in shift | Shift amount | letters | 3 | 0 | 25
out result | Encrypted letter | - | chr(97 + mod(shift, 26)) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →