Modulo 26 keeps a calculation within the 26 positions of the alphabet. With A = 0 and Z = 25, reaching 26 takes you back to A; stepping back to −1 takes you to Z. This wraparound lets a cipher shift every letter, even near the ends of the alphabet.

Keep the result in 0–25

CalculationWrapped indexLetter
25 + 3 = 282C
0 − 3 = −323X
7 + 26 = 337H
4 + 52 = 564E

Wrap beyond Z

InputZEBRA
SettingsCaesar; shift 3; A = 0
Expected resultCHEUD
Try this method

For Z, start at 25 and add 3 to get 28. Subtract 26 to land on 2, or C. If the result is negative, add 26 as many times as needed to reach a position from 0 to 25.

Undo a shift by going the other way

Encoding with Caesar shift 3 adds 3; decoding subtracts 3. Start with C = 2 and calculate 2 − 3 = −1. Wrap that to 25 to get Z back. Adding 3 again would shift the letter farther forward rather than undoing the first move.

If you are writing your own cipher code, watch how your language handles negative remainders. The expression ((n % 26) + 26) % 26 keeps the result in 0–25. It matters when decoding A, B, or C with shift 3, or when using a negative shift.

Why A can be 0 in one method and 1 in another

Caesar and Vigenère formulas count from A = 0. A1Z26 number puzzles count from A = 1 instead. Both conventions work for their own purpose, but swapping one into the other method changes the answer.

Try a negative shift

Encode ABC using shift −3. What normalized shift should the workspace display?

Caesar cipher toolAffine cipher toolVigenère cipher toolWork through Caesar shift 3