Home / Encoding tools / Shift cipher

Shift Cipher

The shift cipher generalised: choose the alphabet and the shift, including negative shifts and shifts larger than the alphabet.

Beyond the Caesar cipher

A shift cipher moves each character a fixed number of places along an alphabet. The Caesar cipher is the case where the alphabet is A to Z. This tool lets you change the alphabet and use any whole number as the shift.

Alphabets

  • Letters A to Z: upper and lower case shift separately, 26 characters each.
  • Letters and digits: letters shift within the alphabet and digits shift within 0 to 9.
  • Printable ASCII: all 95 characters from space to tilde form one ring, so punctuation changes too.
  • Custom alphabet: type your own characters in order, such as a keyboard row. Characters that are not in your alphabet are left alone.

Any shift

Negative shifts move backwards, and shifts larger than the alphabet wrap around. This works because of modular arithmetic: the shift is taken modulo the alphabet size. On a 26-letter alphabet, shifts of 3, 29 and -23 all give the same result.

Decrypting

Choose Decrypt with the same alphabet and shift. For a custom alphabet, you must use exactly the same characters in the same order.

A worked example

With printable ASCII and a shift of 1, the text Hello, World! becomes Ifmmp-!Xpsme". Every character moves to the next one in the ASCII ring, including the comma and the space.

For the classic letters-only version, use the Caesar cipher tool. To break a letters-only cipher, try the decoder. A shift of 13 on letters is ROT13. The guide explains the maths.

Frequently asked questions

What is a shift cipher?

A cipher that replaces each character with one a fixed number of positions along an alphabet. The Caesar cipher is the best-known example.

Can I use a negative shift?

Yes. A negative shift moves backwards, and it gives the same result as the matching positive shift.

What happens to characters outside my alphabet?

They are left unchanged.

How do I decrypt?

Choose Decrypt and use the same alphabet and shift you encrypted with.