The shift cipher is a type of substitution cipher, specifically a monoalphabetic substitution cipher. This means that you replace a letter in the plaintext with the same letter every time. For example, if you replace the letter "A" with "H", you must do that for every "A" in the entire plaintext. The Caesar cipher is probably the most famous shift cipher. It was used by Julius Caesar to send messages to his generals over 2000 years ago.
For a shift cipher, the the shift key is how many letters you shift the plaintext by. The shift can be represented by a number or a letter. The number is easier to understand. A key shift of K=1 means shift every letter to the right 1. The letter key shift states "what does the letter 'A' encrypt to." K=1 means "A" encrypts to "B". So K=1 has the key K="B". It may sound more confusing to do this but representing a key shift as a letter comes in handy with harder shift ciphers and you can make cooler passwords. The following table shows how to relate a key shift to a letter.
Number Shift | Letter Shift |
---|---|
0 | A |
1 | B |
2 | C |
3 | D |
4 | E |
... | ... |
25 | Z |
Let's talk about the Caesar cipher again. It has a key shift of 3. This means the letter "A" is encrypted 3 letters down to "D", "B" is encrypted to "E", and so on. When you reach the end of the alphabet the shift will wrap around to the beginning of the alphabet. For example, "W" encrypts to "Z". "X" ran out of letters, so it wraps over to the beginning of the alphabet at "A". Then "Y" encrypts to "B" and "Z" wraps to "C".
You can have a shift between 0 and 25. Once you pass a key shift of 25, the alphabet is back to "A" -> "A".
Check out the demo below how each letter of the plaintext is mapped to its ciphertext. Click "Shift" to change the key shift.
Here's how we would show the encryption process for the plaintext ATTACK AT DAWN.
Plaintext: | A T T A C K A T D A W N |
Shift Key: 21 ("V"): | V V V V V V V V V V V V |
Ciphertext: | V O O V X F V O Y V R I |
To decrypt you just replace every letter in the ciphertext with its corresponding plaintext letter from the encryption table.
Decrypting | ||
---|---|---|
Ciphertext | R V D O I J O T Z O | |
Plaintext | W A I T N O T Y E T |
Use the tool above to set your key.
It's easy when you have the shift key. When you encrypt a message you shift all the letters to the RIGHT. To decrypt, you shift all the letters LEFT. If the shift key is K=3, then you shift all the letters LEFT by 3 letters.
Use the shift tool from above.