2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00
LaTeX-examples/tikz/CBC-Mode-Encryption/CBC-Mode-Encryption.tex
Martin Thoma 7740f0147f Remove trailing spaces
The commands

find . -type f -name '*.md' -exec sed --in-place 's/[[:space:]]\+$//' {} \+

and

find . -type f -name '*.tex' -exec sed --in-place 's/[[:space:]]\+$//' {} \+

were used to do so.
2015-10-14 14:25:34 +02:00

50 lines
1.6 KiB
TeX

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{preview}
% thanks to http://tex.stackexchange.com/a/75838/5645
\tikzset{XOR/.style={fill=black!15,draw,minimum size=13pt,circle,append after command={
[shorten >=\pgflinewidth, shorten <=\pgflinewidth,]
(\tikzlastnode.north) edge (\tikzlastnode.south)
(\tikzlastnode.east) edge (\tikzlastnode.west)
}
}
}
\tikzstyle{encrypt}=[draw,fill=black!15,rectangle,minimum size=20pt,inner sep=0pt]
\begin{tikzpicture}
\newcommand{\n}{3}
\foreach \nr in {1, ..., \n}{
\node (M\nr) at (0,{(\n-\nr)*2}) {$M_\nr$};
\node (x\nr)[XOR] at (2,{(\n-\nr)*2}) {};
\node (E\nr)[encrypt] at (4,{(\n-\nr)*2}) {$E$};
\node (C\nr) at (6,{(\n-\nr)*2}) {$C_\nr$};
\node (K\nr) at (4,{(\n-\nr)*2+1}) {$K$};
\draw[->,very thick] (M\nr) -- (x\nr);
\draw[->,very thick] (x\nr) -- (E\nr);
\draw[->,very thick] (E\nr) -- (C\nr);
\draw[->,very thick] (K\nr) -- (E\nr);
}
\foreach \nr in {2, ..., \n}{
\pgfmathtruncatemacro{\tmp}{\nr-1}
\draw[->,very thick] (E\tmp) -- (4, {(\n-\tmp)*2-0.5}) -- (2, {(\n-\nr)*2+1.5}) -- (x\nr);
}
\node (IV) at (2,{\n*2-1}) {$IV$};
\draw[->, very thick] (IV) -- (x1);
\node (Mx) at (0,-1) {$\vdots$};
\node (xx) at (2,-1) {$\vdots$};
\node (Ex) at (4,-1) {$\vdots$};
\node (Cx) at (6,-1) {$\vdots$};
\end{tikzpicture}
\end{preview}
\end{document}