Skip to main content
Contents Index
Dark Mode Prev Up Next
\(\newcommand{\im}{{\mathrm{im}}}
\newcommand{\given}{{\, :\,}}
\newcommand{\hanoi}{\mathrm{hanoi}}
\newcommand{\lcm}{{\mathrm{lcm}}}
\newcommand{\ID}{{\mathrm{ID}}}
\newcommand{\chr}{{\mathtt{chr}}}
\newcommand{\ord}{{\mathtt{ord}}}
\newcommand{\set}[1]{\left\lbrace #1 \right\rbrace}
\newcommand{\seq}[2]{( #1 )_{#2}}
\newcommand{\gr}[1]{\left( #1 \right)}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\size}[1]{\# #1}
\newcommand{\id}[1]{\mathrm{id}_{#1}}
\newcommand{\ip}[1]{\left\langle #1 \right\rangle}
\newcommand{\floor}[1]{\left\lfloor #1\right\rfloor}
\newcommand{\ceiling}[1]{\left\lceil #1\right\rceil}
\newcommand{\indemph}[1]{{\textbf{\emph{#1}}\index{#1}}}
\renewcommand{\implies}{\to}
\renewcommand{\iff}{\leftrightarrow}
\newcommand{\lxor}{\oplus}
\newcommand{\cP}{\wp}
\newcommand{\pset}{\cP}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\barr}[1]{\overline{#1}}
\newcommand{\sage}{\textsc{Sage}}
\newcommand{\magma}{\textsc{Magma}}
\newcommand{\bob}{\text{Bob}}
\newcommand{\true}{\text{T}}
\newcommand{\false}{\text{F}}
\newcommand{\ahat}{\hat{a}}
\newcommand{\ah}{\ahat}
\newcommand{\bhat}{\hat{b}}
\newcommand{\abar}{\bar{a}}
\newcommand{\cA}{\mathcal{A}}
\newcommand{\cF}{\mathcal{F}}
\newcommand{\cW}{\mathcal{W}}
\newcommand{\todo}[1]{{\color{red} TODO: #1}}
\renewcommand{\div}{\operatorname{div}}
\newcommand{\gexp}[3]{#1^{#2 #3}}
\newcommand{\gexpp}[3]{\displaystyle\left(#1\right)^{#2 #3}}
\newcommand{\glog}[3]{\log_{#1}^{#3}#2}
\def\dbend{{!!!}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Subsection 5.5.1 Shift ciphers
We want a method to encrypt, or make secret, a plain text message. One of the earliest know approaches was by Julius Caesar. The idea was to basically shift the alphabet by
\(3\) spots.
Definition 5.5.1.1 .
The
Caesar cipher is the shift cipher, where we shift forward by three.
Here are the steps to encrypt using the Caesar cipher.
Replace each letter in the message by an element of
\(\ZZ_{26}\) equal to 1 less than its position in the alphabet. For example, A is replaced by
\(0\text{,}\) B is replaced by
\(1\text{,}\) \dots, Z is replaced by
\(25\text{.}\) In this step, we are
encoding
Replace each number
\(p\) by
\((p + 3)\bmod 26\text{.}\) Equivalently, apply the function
\(f \colon \ZZ_{26} \to \ZZ_{26}\) defined by
\(f(x) = x + 3 \bmod 26\) to each number. This step does the
encrypting .
Translate the numbers back to letters.
Example 5.5.1.2 .
Letβs encrypt CAT using the Caesar cipher.
First, we change CAT to numbers, we get 2 0 19. Apply \(f\) to get 5 3 22. Translate back to letters to get FDW.
\begin{align*}
\text{C}\amp\xrightarrow{\text{encode}} 2 \xrightarrow{\text{encrypt}}
5 \xrightarrow{\text{decode}} \text{F}\\
\text{A}\amp \xrightarrow{\text{encode}} 0 \xrightarrow{\text{encrypt}}
3 \xrightarrow{\text{decode}} \text{D}\\
\text{T}\amp \xrightarrow{\text{encode}} 19 \xrightarrow{\text{encrypt}}
22 \xrightarrow{\text{decode}} \text{W}
\end{align*}
If we were going to encrypt longer messages, it would be faster to precompute a lookup table as shown in
TableΒ 5.5.1.3 .
Table 5.5.1.3.
A
B
C
D
E
F
G
H
I
J
K
L
M
D
E
F
G
H
I
J
K
L
M
N
O
P
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
Figure 5.5.1.5. Privacy Opinions. (https://xkcd.com/1269/ ) Iβm the Philosopher until someone hands me a burrito.