📚 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}19\newcommand{\n}{3}20\foreach \nr in {1, ..., \n}{21\node (M\nr) at (0,{(\n-\nr)*3}) {$C_\nr$};22\node (x\nr)[XOR] at (2,{(\n-\nr)*3}) {};23\node (E\nr)[encrypt] at (2,{(\n-\nr)*3+1}) {$E$};24\node (K\nr) at (2,{(\n-\nr)*3+2}) {$K$};25\node (C\nr) at (4,{(\n-\nr)*3}) {$M_\nr$};2627\draw[->,very thick] (M\nr) -- (x\nr);28\draw[->,very thick] (x\nr) -- (C\nr);29\draw[->,very thick] (K\nr) -- (E\nr);30\draw[->,very thick] (E\nr) -- (x\nr);31}3233\foreach \nr in {2, ..., \n}{34\pgfmathtruncatemacro{\tmp}{\nr-1}35\draw[->,very thick] (2, {(\n-\tmp)*3+0.5}) -- (1, {(\n-\tmp)*3+0.5}) -- (1, {(\n-\nr)*3+1}) -- (E\nr);36}3738\node (IV) at (0.5,{\n*3-2}) {$IV$};39\draw[->, very thick] (IV) -- (E1);4041\node (Mx) at (0,-1) {$\vdots$};42\node (xx) at (2,-1) {$\vdots$};43\node (Ex) at (4,-1) {$\vdots$};44\end{tikzpicture}45\end{preview}46\end{document}474849