In the summer of 2021, I started to do a Python and Java workshop at Scholetech, which was led by my dad, Manoj Rajan. Near the end of the workshop, we started on a new project, where we created a cipher program. In the program, we created a secret code, and made an option to cipher and decipher messages that the user inputs. 

Before programming the project, we talked about how to use dictionaries in Python. Dictionaries are sets of data that have keys and definitions, and it functions almost like a real dictionary. You could even create your own real dictionary with this, by adding words into the keys and following with their definitions. A dictionary is similar to a set or a list, which are both other ways to store data in Python. The three requirements for a dictionary are: keys, terms, and a dictionary name. With all three requirements and the right formatting, anyone can create a dictionary. 

One thing that you can use dictionaries for is to create a cipher, like I mentioned before. A cipher is ‘a secret or disguised way of writing; a code’. You see ciphers being used almost everywhere- including in encrypted messaging online, so hackers will not be able to find out what you are texting your friends! There are also many different types of ciphers. For example, a Caesar Cipher. A Caesar Cipher is a type of cipher where each letter or character is replaced with another letter or character. Let’s say that anytime we type an ‘h’, it will be encrypted into ‘c’. And everytime we type an ‘i’, it will be encrypted into an ‘a’. That means, when a user tries to encrypt the message ‘hi!’- the output would be ‘ca!’. This is a very simple and basic type of cipher, and it is the type that we programmed in the workshop.

To program this cipher tool, I had to go about different ways of coding it. It took hours of coding, debugging, and plain thinking to reach my final result. I was confused on how to even go about starting it. And in the middle of it all, I bugged my entire code by missing a single colon. But in the end, I successfully completed the program by using one solution. My solution was to create two libraries- one for encrypting and one for decrypting. For the actual secret code, I used different characters like ‘!’ for ‘a’, and ‘@’ for b. And I put this code into one dictionary named “encrypting”. This way, when a user enters a normal message like: ‘hi dia!’, it would result in something that looked like ‘?& #%!”. Then, in a second dictionary, I added the same secret code- but this time, instead of putting the regular letters as the terms, I put them into the definition column. Because of this, I could simply create another while loop and let the program accept coded information, and output decoded information. 

While this was a good way about solving the problem, I definitely believe I could have found a better way to code it. Later in the workshop, we learned how to code our own commands, which I find would be helpful in coding a much more efficient Caesar Cipher. It would allow me to use simply one dictionary, and shorten my code immensely. But in all, the workshop was very helpful, and as a beginner I learned a lot about both Python and Java that will for certain help me in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *