Caesar cipher encryption

Caesar cipher encryption is one of the first historically known encryption methods. Julio César used it to send orders to his generals on the battlefields. It consisted of writing the message with an alphabet that was formed by the letters of the normal Latin alphabet displaced three positions to the right. With our alphabet the system would look like this:

Clear alphabet: A B C D E F G H I J K L M N Ñ O P Q R S T U V W X Y Z
Encrypted alphabet: D E F G H I J K L M N Ñ O P Q R S T U V W X Y Z A B C
For example, if you want to send the message ATACARALAMANECER, what will really be written is DWDFDUDÑDODPHFHU

The recipient of the message knew its secret key (that is, it was written with an alphabet shifted three positions to the right), and could easily decipher it by reversing with each letter of the message. But for the rest of the people who could accidentally get to see the message, the text was meaningless.

Apparently it is very weak and unsafe encryption, but at the time of Julius Caesar the idea of ​​hiding the meaning of a text through encryption was not widely known. In fact, that a message was written was already a way of ensuring confidentiality vis-à-vis the majority of the illiterate population of the time.

As a curious fact, more than 1500 years later, an encryption similar to that of César was used by Queen Maria Estuardo of Scotland, to conspire together with the Spaniards against her cousin Isabel I (in fact, she was encouraged to conspire by agents in the service of Isabel I; a well-warped trap.) Maria’s encrypted messages were easily deciphered by simple statistical analyzes by the agents of Isabel I, and thus the conspiracy of the Scottish queen was exposed. Along with the loss of the secret of the communication, Maria lost her mind in her execution on February 8, 1587. After this, César encryption was definitely ruled out as a secure encryption method for the rulers of the world. From then until today, the ciphers used by the states to preserve their secrets have improved considerably.

What we are interested in Caesar cypher encryption is that it is a clear example of using modular arithmetic to guarantee the confidentiality of information through encryption or encryption. Mathematically, we can describe the method used by Julius Caesar as a linear function of the type

E (x) = x + 3 (mod 27)

for an alphabet with 27 characters. The x indicates the position that the letter “in clear” occupies in alphabet. E (x) indicates the position of the encrypted letter corresponding to x in the alphabet. According to this, E (0) = 3, and E (26) = 2 (that is, a is encrypted as d, and z as c)

 

To decrypt the function D (x) = x-3 (mod 27) is used. To encrypt and decrypt the message, the communicators must know and use the same secret key, which in this case is the displacement applied to the alphabet (displacement = 3). That is why Caesar cipher encryption belongs to private key encryption, also called symmetric encryption.