📚 The CoCalc Library - books, templates and other resources
License: OTHER
\documentclass{article}1\usepackage[pdftex,active,tightpage]{preview}23\usepackage{tikz}4\usetikzlibrary{calc}56\begin{document}7\begin{preview}8% thanks to http://tex.stackexchange.com/a/75838/56459\tikzset{XOR/.style={fill=black!15,draw,minimum size=13pt,circle,append after command={10[shorten >=\pgflinewidth, shorten <=\pgflinewidth,]11(\tikzlastnode.north) edge (\tikzlastnode.south)12(\tikzlastnode.east) edge (\tikzlastnode.west)13}14}15}1617\tikzstyle{encrypt}=[draw,fill=black!15,rectangle,minimum size=20pt,inner sep=0pt]18\begin{tikzpicture}19TODO20\newcommand{\n}{3}21\foreach \nr in {1, ..., \n}{22\node (C\nr) at (0,{(\n-\nr)*3}) {$C_\nr$};23\node (x\nr)[XOR] at (2,{(\n-\nr)*3}) {};24\node (D\nr)[encrypt] at (2,{(\n-\nr)*3+1}) {$E$};25\node (K\nr) at (2,{(\n-\nr)*3+2}) {$K$};26\node (M\nr) at (4,{(\n-\nr)*3}) {$M_\nr$};2728\draw[->,very thick] (C\nr) -- (x\nr);29\draw[->,very thick] (x\nr) -- (M\nr);30\draw[->,very thick] (K\nr) -- (D\nr);31\draw[->,very thick] (D\nr) -- (x\nr);32}3334\foreach \nr in {2, ..., \n}{35\pgfmathtruncatemacro{\tmp}{\nr-1}36\draw[->,very thick] (1, {(\n-\tmp)*3}) -- (1, {(\n-\nr)*3+1}) -- (D\nr);37}3839\node (IV) at (0.5,{\n*3-2}) {$IV$};40\draw[->, very thick] (IV) -- (D1);4142\node (Mx) at (0,-1) {$\vdots$};43\node (xx) at (2,-1) {$\vdots$};44\node (Ex) at (4,-1) {$\vdots$};45\end{tikzpicture}46\end{preview}47\end{document}484950