top of page

My frustration with being a techno-infant

  • Writer: shawn gibford
    shawn gibford
  • Aug 4, 2021
  • 2 min read

ree

In order to get better at encryption, I need to know how to code.


This is a problem because I have attempted numerous different times to teach myself Python because, well, its the popular language and its functional.


Python can be downloaded here easily enough. I chose to use VSCode as my IDE on recommendation from a developer whom, once switching from Atom said, they never looked back.


I am still having difficulty navigating the IDE which I guess will be fixed in time enough.


The famous Caesar Cipher is a simple enough thing to discuss. You have your cleartext, you move it by key, say 5, and then the letters in your message get moved 5 letters down the alphabet, you are then left with your ciphertext.


This is the most elementary form of encryption and a seemingly great place to start on my journey to encryption enlightenment.


Sources for this experiment can be found here, here, here, and, here.


Once I had the VSCode loaded and had cleared out the welcome wagon (which took far longer than I thought) it was time to start the whole thing that I have been trying to avoid doing for almost ten years: coding.


First I needed to create a variable for the plaintext

ree

Next came the alphabet variable, this allows me a "dictionary" of letters to manipulate

ree

The key variable is the amount the plaintext will be moved, the oomph, to the Caesar Cipher

ree

Here is where the ciphertext will be stored.

ree

I was intimidated by this code the first time I saw it but after a while it ended up making a lot of sense. Using a bit of math found on the Wikipedia page will actually break this down into easier to understand terms.

The Code: for/if loop is basically connecting the plaintext and alphabet variables, which

will allow me to do operations on them concerning the other.

'cipher +=' lets the argument on the other side be passed throw into the 'cipher' variable


The Math: En(x) = (x + n) mod 26


Scary, I know, but not really, I promise.


The equation states that Encrypted-X is just equal to X plus N (our key, in this example it is 5) modulus 26, the number of characters in our alphabet. The modulus operator returns the remainder of a function if the answer to it is outside the bounds of the question.


Example: If our key was 1, A would equal B.

If our key was 26, A would equal A

If our key was 27, A would equal B.

27%26 returns 1, A plus 1 equals B


You see this in the right hand side of the argument.

(C-Key)%26

ree

Print function to display the ciphertext post-encryption.

ree



All in all this was incredible simple, however, the lessons I have taken away from this will be indispensable.


I will be doing much more of this kind of thing in the future as my coding and encryption skills grow.

Comments


Drop Me a Line, Let Me Know What You Think

Thanks for submitting!

© 2023 by Train of Thoughts. Proudly created with Wix.com

bottom of page