\documentclass[10pt,envcountsect]{beamer}

\mode<presentation> {
  \usetheme{Warsaw}
}

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{pstricks,pstricks-add,pst-math,pst-xkey}
\usepackage{multicol}


\begin{document}

\title{Episode 09 -- The Caesar cipher}
\subtitle{European section -- Season 3}
\author{}
\date{}

\begin{frame}
  \titlepage
\end{frame}

\begin{frame}{Why Caesar ?}

\begin{center}
\includegraphics[scale=0.3]{images/caesar.eps}
\end{center}

\end{frame}

\begin{frame}{Suetonius, Life of Julius Caesar}

\begin{multicols}{2}
\includegraphics[scale=0.5]{images/suetonius.eps}

{\large ``If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out. If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others.''}

\end{multicols}

\end{frame}


\begin{frame}{A Caesar cipher with a shift of three}

\begin{center}
\includegraphics[scale=0.4]{images/caesarcipher3.eps}
\end{center}


\end{frame}

\begin{frame}{An example}

\begin{center}\huge
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
v & e & n & i & v & i & d & i & v & i & c & i \\
\hline
Y & H & Q & L & Y & L & G & L & Y & L & F & L \\
\hline
\end{tabular}
\end{center}

\end{frame}


\begin{frame}{The implementation chain}

\newcommand{\cle}{\newrgbcolor{fefefe}{1 1 1}
\newrgbcolor{qrqrqr}{0 0 0}
\psset{xunit=0.1cm,yunit=0.1cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(0.06,-1.36)(11.64,4.22)
\pspolygon[linecolor=qrqrqr,fillcolor=qrqrqr,fillstyle=solid](4.44,1.82)(4.44,1.2)(11.32,1.2)(11.32,1.82)
\pspolygon[linecolor=qrqrqr,fillcolor=qrqrqr,fillstyle=solid](9.92,1.82)(9.92,0.3)(10.64,0.3)(10.64,1.82)
\pscircle[fillcolor=black,fillstyle=solid](2.46,1.44){0.22}
\pscircle[linecolor=fefefe,fillcolor=fefefe,fillstyle=solid](2.46,1.44){0.16}
\psline(4.44,1.82)(11.32,1.82)
\psline[linecolor=qrqrqr](4.44,1.82)(4.44,1.2)
\psline[linecolor=qrqrqr](11.32,1.2)(11.32,1.82)
\psline[linecolor=qrqrqr](11.32,1.82)(4.44,1.82)
\psline[linecolor=qrqrqr](9.92,1.82)(9.92,0.3)
\psline[linecolor=qrqrqr](9.92,0.3)(10.64,0.3)
\psline[linecolor=qrqrqr](10.64,0.3)(10.64,1.82)
\psline[linecolor=qrqrqr](10.64,1.82)(9.92,1.82)
\end{pspicture*}}

\newcommand{\algo}{
\newrgbcolor{qrqrqr}{0 0 0}
\psset{unit=0.75cm}
\begin{pspicture}(0,0)(1,1)
\pspolygon[linecolor=qrqrqr,fillcolor=qrqrqr,fillstyle=solid](0,0)(0,1)(1,1)(1,0)
\end{pspicture}

}


\begin{center}
\psset{nodesep=3pt}
\begin{tabular}{ccccc}
Sender & & & & Receiver \\[15pt]
\rnode{A}{\fbox{\parbox{1.5cm}{\tiny This is plain text, that anyone could read if it were sent without being encoded.}}} & & & & \rnode{F}{\fbox{\parbox{1.5cm}{\tiny This is plain text, that anyone could read if it were sent without being encoded.}}} \\[5pt]
\small Plaintext & & & &\small  Plaintext  \\[10pt]
 & \rnode{C}{\algo} & \parbox{1.7cm}{\rnode{D}{\fbox{\parbox{1.5cm}{\tiny Wklv lv hq hqfubswhg whaw xquhdgdeoh zlwkrxw iluvw ehlqj ghfubswhg.}}}\vspace{0.5cm}}  & \rnode{E}{\algo} &  \\[5pt]
 & \small Algorithm & \small Ciphertext & \small Algorithm &  \\[10pt]
\rnode{B}{\cle} & & & & \rnode{G}{\cle} \\
\small Key & & & &\small  Key \\[10pt]
\end{tabular}
\ncline{->}{A}{C}
\ncline{->}{B}{C}
\ncline{->}{C}{D}
\ncline{->}{D}{E}
\ncline{->}{E}{F}
\ncline{->}{E}{G}
\end{center}

\end{frame}

\begin{frame}{Advantages and drawbacks}

\LARGE
\begin{itemize}
\item {\green Easy to implement.}
\item {\green Offers a minimun of secrecy.}
\item {\red Easy to decipher.}
\end{itemize}


\end{frame}

\begin{frame}{Your tasks}

\Large

\begin{enumerate}
\item Choose a partner far away in the class. 
\item Decide on a shift.
\item Write a short message in plain text (lower-case), then encipher it (upper-case).
\item Send the ciphertext to its destination, trough the teacher.
\item Decode the message you received.
\item Try to decode intercepted messages without knowing the key (working in pairs).
\end{enumerate}



\end{frame}




\end{document}
