Caesar Cipher in Python

An introduction into the cryptography world and a simple way to learn a new language.

Fernando Souza
Vacatronics

--

By Matt_Crypto — http://en.wikipedia.org/wiki/File:Caesar3.png, Public Domain, https://commons.wikimedia.org/w/index.php?curid=30693472

When we are trying to learn a new programming language, we usually try to solve a few problems and algorithms that help us in this process. The Caesar Cipher algorithm is a very simple kind of cryptography (please, don’t use it in a real application) and is a good start with a new language.

Definition

The Caesar Cipher is a famous and very old cryptography technique. In a simple way, it reorganize all the letter from a sentence based on a shifted alphabet.

For example, if we choose a right shift of 4, the letter A is replaced by E, B is replaced by F, and so on. When the end of alphabet is reached, it returns back to the beginning.

So, if we have the following message:

hello world

would produce something like this:

lipps Bsvph

The message becomes a little bit harder to read. This method was named after Julius Caesar (yes, him), who used in its private correspondence.

Algorithm

To implement this cipher technique, we need a few simple steps:

  1. Identify the character in the…

--

--

Fernando Souza
Vacatronics

Enthusiast of programming, electronics, technology and beer, not necessarily in that order. BuyMeACoffee: buymeacoffee.com/ustropo