Caesar Cipher

In cryptography, a Caesar cipher, also known as shift cipher, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.

The action of a Caesar cipher is to replace each plaintext letter with a different one a fixed number of places down the alphabet.

Caesar_cipher_left_shift_of_3

The cipher illustrated above uses a left shift of three, so that each occurrence of E in the plaintext becomes B in the ciphertext.

The transformation can be represented by aligning two alphabets; the cipher alphabet is the plain alphabet rotated left or right by some number of positions. For instance, here is a Caesar cipher using a left rotation of three places, equivalent to a right shift of 23 (the shift parameter is used as the key):

Plain:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

When encrypting, a person looks up each letter of the message in the “plain” line and writes down the corresponding letter in the “cipher” line.

Plaintext:  THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD

Deciphering is done in reverse, with a right shift of 3.

The encryption can also be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A = 0, B = 1,…, Z = 25.[2] Encryption of a letter x by a shift n can be described mathematically as,

caesar-cypher-encoding

Decryption is performed similarly,

caesar-cypher-decoding

The Caesar cipher is named after Julius Caesar, who used it, more than 2000 years ago, to protect messages of military significance.

julius-caesar

Vercingetorix throws down his arms at the feet of Julius Caesar. Painting by Lionel Royer – Musée CROZATIER du Puy-en-Velay – France, Public Domain.

Caesar Cipher Wheel


A cipher wheel is a tool used to help decipher a message encrypted using the Caesar cipher:

Encrypted Message


Use a Python program to decode the following secret message:

caesar-encode-message
N qtaj uwtlwfrrnsl zxnsl Udymts!
Key: right shift by 5 characters


unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 44

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,