If any value becomes negative after subtraction, the modulo operator will take care of that, and it will wrap it around. The meaning of the notations remains the same as in the previous formula. Let’s now check out the same for the decryption process. # since character is not uppercase, leave it as it isĮarlier, we looked at the mathematic formulation of the encryption process. # check if character is an uppercase letter Let us now look at the code: shift = 3 # defining the shift count
The computer doesn’t understand any of our English language’s alphabet or other characters by itself.Įach of these characters is represented in computer memory using a number called ASCII code (or its extension – the Unicode) of the character, which is an 8-bit number and encodes almost all the English language’s characters, digits, and punctuations.įor instance, the uppercase ‘A’ is represented by the number 65, ‘B’ by 66, and so on.
It is important to realize that the alphabet as we know them, is stored differently in a computer’s memory. Before we dive into defining the functions for the encryption and decryption process of Caesar Cipher in Python, we’ll first look at two important functions that we’ll use extensively during the process – chr() and ord().