📚 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)*2}) {$M_\nr$};22\node (x\nr)[XOR] at (2,{(\n-\nr)*2}) {};23\node (E\nr)[encrypt] at (4,{(\n-\nr)*2}) {$E$};24\node (C\nr) at (6,{(\n-\nr)*2}) {$C_\nr$};2526\node (K\nr) at (4,{(\n-\nr)*2+1}) {$K$};2728\draw[->,very thick] (M\nr) -- (x\nr);29\draw[->,very thick] (x\nr) -- (E\nr);30\draw[->,very thick] (E\nr) -- (C\nr);3132\draw[->,very thick] (K\nr) -- (E\nr);33}3435\foreach \nr in {2, ..., \n}{36\pgfmathtruncatemacro{\tmp}{\nr-1}37\draw[->,very thick] (E\tmp) -- (4, {(\n-\tmp)*2-0.5}) -- (2, {(\n-\nr)*2+1.5}) -- (x\nr);38}3940\node (IV) at (2,{\n*2-1}) {$IV$};41\draw[->, very thick] (IV) -- (x1);4243\node (Mx) at (0,-1) {$\vdots$};44\node (xx) at (2,-1) {$\vdots$};45\node (Ex) at (4,-1) {$\vdots$};46\node (Cx) at (6,-1) {$\vdots$};47\end{tikzpicture}48\end{preview}49\end{document}505152