Ceasar Cipher

In this document, we will discuss the Ceasar Cipher, which is one of the earlier methods of encryption, and was implemented by assigning each letter a number, such as $a\rightarrow 1$, and then computing \[ c = m+a \:(\text{mod } 26) \] where $m$ is the original message, $a$ is some preselected encrypting key, and $c$ is the ciphertext. We can implement this in SageMath with the following code.

Note that in this document, the encryption scheme we actualy present here is the affine map, given by \[ c = a*m+b \:(\text{mod } 26) \] where $\gcd(a,26)=1$, $m$ is the plain text, and $c$ is the cipher text. Decryption is then given by the inverse map, which exists since we chose $a$ such that $\gcd(a,26)=1$. \[ m = a^{-1}*c-a^{-1}b \:(\text{mod }26) \]

Example

Here is a working example of using this affine cipher, with parameters $a=5$ and $b=4$. Be sure to run the above cell first to define all necesary functions.