Skip to content

sito8943/caesar-rotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DNI

Julius Caesar the perpetual dilator used a code when he wanted to keep a message secret. The encryption consisted of substituting the first letter of the alphabet, A, for the fourth, D, and so on with the others, that is, the second, B, for the fifth, E, the third, C, for the sixth, F. ...
The Latin alphabet used by Julius Caesar consisted of 21 letters, therefore the substitution of letters to encrypt or decrypt messages was described in the following table

A B C D E F G H I J K L M N O P Q R S T U V
D E F G H I J K L M N O P Q R S T V A B C

But we will use the spanish alphabet in this case

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
D E F G H I J K L M N Ñ O P Q R S T V W X Y Z A B C

To encrypt a message, for example a phrase that the emperor pronounced, "ALEA IACTA EST" (the die is cast), just look for the letter written in the first row of the previous table and write the letter that is in the row of below. The decryption procedure is the reverse; Given an encrypted message, each letter in the message is looked up in the row below and the letter in the row above is written.


Result:
A L E A I A C T A E S T
D O H D M D F A D H A B

This result was obtained by executing the code with the Latin alphabet, it is up to you to run it with your alphabet


This type of encryption is a substitution code, since each letter is replaced by another. More specifically, we can say that it is a rotation code, since two consecutive letters of the original alphabet correspond to two consecutive letters of the encrypted alphabet (if we consider a circular representation of the alphabet)

To run: npm run start [-- text]