Following with an activity that we did a few weeks ago (https://www.europeanvalley.es/noticias/cifrar-mensajes-en-clase/), where with 6º elementary students we work on the encryption of messages in mathematics, I decided to continue working with this activity in a scalar way.

With my programming students, who are working on Python, I proposed the following challenge:

**"To be able to create its own Enigma machine based on the Cesar encryption method"**

For the introduction of the theory, I simply relied on my article of "Cryptography in Class", where I explain what this method consists of and how it is used.

The way of working this activity is by teams of 3 or 4 students, since the programming is a bit complex and more productive to work in cooperative, also the objective of the activity is to create several enigmas machines in class and that can be encrypted and deciphered the same messages on different machines, that is, in different codes.

To facilitate this activity and that you can perform in class I leave you on the one hand the flow diagram of the function **CODE**, from which, in a simple way you can take out the **DECIPHER**.

On the other hand I leave the full code of the program made in Python.

#Focus function where you need two values**def encrypt (text, password):**** length = len (text); #We calculate the length of the text to go through it**** for i in range (0, length): #Loop to scroll the text**** for pos in range (0,26): #Loop to travel the alphabet**** if text [i] == abc [pos]: # I compare the letters one by one**** pos_abc = pos + int (password) #I move in the alphabet according to the password**** if pos_abc <26:**** print (abc [pos_abc], end = »»)**** if pos_abc> 25: #In the case that happens to me of the alphabet, I calculate the module**** print (abc [pos_abc% 26], end = »»)**** else:**** print (end = »«)**** return**

# Decipher function where you need two values**def decrypt (text, password):**** length = len (text);**** for i in range (0, length):**** for pos in range (0,26):**** if text [i] == abc [pos]:**** pos_abc = pos- (int (key))**** if pos_abc> -1:**** print (abc [pos_abc], end = »»)**** if pos_abc <0:**** print (abc [pos_abc% 26], end = »»)**** else:**** print (end = »«)**** return****print («The utility of this program is to encrypt or decrypt the text you enter using the César method. \ n —————————————————–«)****text = input («Tell me the text:«)****key = input («Tell me the key:«)****abc = [«a», »b», »c», »d», »e», »f», »g», »h», »i», »j», »k», »l» , »M», »n», »o», »p», »q», »r», »s», »t», »u», »v», »w», »x», » and Z"," "]****print («1.-Encrypt \ n2.-Decipher \ n —————————————«)****option = input («Choose an option:«)****if option == »1 ″:**

**encrypt (text, password)** # I call the function passing the text and the encryption key**if option == "2":**** decipher (text, password)** # I call the function passing the text and the encryption key

You also have it available in my repository of GitHub