Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Last active December 6, 2016 18:30
Show Gist options
  • Save sonOfRa/1f92c004e8d0d71b273adbd1109b5139 to your computer and use it in GitHub Desktop.
Save sonOfRa/1f92c004e8d0d71b273adbd1109b5139 to your computer and use it in GitHub Desktop.
DES Typesetting. License: CC0.
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,calc}
\tikzset{XOR/.style={draw,minimum width=0.5cm,circle,append after command={
[shorten >=\pgflinewidth, shorten <=\pgflinewidth,]
(\tikzlastnode.north) edge (\tikzlastnode.south)
(\tikzlastnode.east) edge (\tikzlastnode.west)
}
}
}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[>=latex]
\node (RI) {$R_i$};
\node[draw,minimum height=1cm,minimum width=2cm,right=1cm of RI] (E) {$E$};
\draw [->] (RI) -- node [strike out,draw,-,label=above:32] {} (E);
\node[XOR,minimum height=1cm,right=1cm of E] (XOR) {};
\draw [->] (E) -- node [strike out,draw,-,label=above:48] {} (XOR);
\node[below=2cm of XOR] (KI) {$K_i$};
\draw [->] (KI) -- node [strike out,draw,-,label=right:48] {} (XOR);
\coordinate[right=1cm of XOR] (FORK) {};
\draw [-] (XOR) -- node [strike out,draw,-,label=48] {} (FORK);
\coordinate[above=0.75cm of FORK] (S4ANCHOR) {}
edge [-] (FORK);
\node[right=1cm of S4ANCHOR,draw,minimum height=1cm,minimum width=1cm] (S4) {$S_4$};
\draw [->] (S4ANCHOR) -- node [strike out,draw,-,label=6] {} (S4);
\coordinate[right=1cm of S4] (S4OUT) {};
\draw [-] (S4) -- node [strike out,draw,-,label=4] {} (S4OUT);
\coordinate[below=0.75cm of S4OUT] (CONVERGE) {}
edge [-] (S4OUT);
\node[right=1cm of CONVERGE,draw,minimum height=1cm,minimum width=2cm] (P) {$P$};
\draw [->] (CONVERGE) -- node [strike out,draw,-,label=32] {} (P);
\node[right=1cm of P] (OI) {$O_i$};
\draw [->] (P) -- node [strike out,draw,-,label=32] {} (OI);
\coordinate[above=1.5cm of S4ANCHOR] (S3ANCHOR) {}
edge [-] (S4ANCHOR);
\node[right=1cm of S3ANCHOR,draw,minimum height=1cm, minimum width=1cm] (S3) {$S_3$};
\draw [->] (S3ANCHOR) -- node [strike out,draw,-,label=6] {} (S3);
\coordinate[right=1cm of S3] (S3OUT) {}
edge [-] (S4OUT);
\draw [-] (S3) -- node [strike out,draw,-,label=4] {} (S3OUT);
\coordinate[above=1.5cm of S3ANCHOR] (S2ANCHOR) {}
edge [-] (S3ANCHOR);
\node[right=1cm of S2ANCHOR,draw,minimum height=1cm, minimum width=1cm] (S2) {$S_2$};
\draw [->] (S2ANCHOR) -- node [strike out,draw,-,label=6] {} (S2);
\coordinate[right=1cm of S2] (S2OUT) {}
edge [-] (S3OUT);
\draw [-] (S2) -- node [strike out,draw,-,label=4] {} (S2OUT);
\coordinate[above=1.5cm of S2ANCHOR] (S1ANCHOR) {}
edge [-] (S2ANCHOR);
\node[right=1cm of S1ANCHOR,draw,minimum height=1cm,minimum width=1cm] (S1) {$S_1$};
\draw [->] (S1ANCHOR) -- node [strike out,draw,-,label=6] {} (S1);
\coordinate[right=1cm of S1] (S1OUT) {}
edge [-] (S2OUT);
\draw [-] (S1) -- node [strike out,draw,-,label=4] {} (S1OUT);
\coordinate[below=0.75cm of FORK] (S5ANCHOR) {}
edge [-] (FORK);
\node[right=1cm of S5ANCHOR,draw,minimum height=1cm,minimum width=1cm] (S5) {$S_5$};
\draw [->] (S5ANCHOR) -- node [strike out,draw,-,label=6] {} (S5);
\coordinate[right=1cm of S5] (S5OUT) {}
edge [-] (CONVERGE);
\draw [-] (S5) -- node [strike out,draw,-,label=4] {} (S5OUT);
\coordinate[below=1.5cm of S5ANCHOR] (S6ANCHOR) {}
edge [-] (S5ANCHOR);
\node[right=1cm of S6ANCHOR,draw,minimum height=1cm,minimum width=1cm] (S6) {$S_6$};
\draw [->] (S6ANCHOR) -- node [strike out,draw,-,label=6] {} (S6);
\coordinate[right=1cm of S6] (S6OUT) {}
edge [-] (S5OUT);
\draw [-] (S6) -- node [strike out,draw,-,label=4] {} (S6OUT);
\coordinate[below=1.5cm of S6ANCHOR] (S7ANCHOR) {}
edge [-] (S6ANCHOR);
\node[right=1cm of S7ANCHOR,draw,minimum height=1cm,minimum width=1cm] (S7) {$S_7$};
\draw [->] (S7ANCHOR) -- node [strike out,draw,-,label=6] {} (S7);
\coordinate[right=1cm of S7] (S7OUT) {}
edge [-] (S6OUT);
\draw [-] (S7) -- node [strike out,draw,-,label=4] {} (S7OUT);
\coordinate[below=1.5cm of S7ANCHOR] (S8ANCHOR) {}
edge [-] (S7ANCHOR);
\node[right=1cm of S8ANCHOR,draw,minimum height=1cm,minimum width=1cm] (S8) {$S_8$};
\draw [->] (S8ANCHOR) -- node [strike out,draw,-,label=6] {} (S8);
\coordinate[right=1cm of S8] (S8OUT) {}
edge [-] (S7OUT);
\draw [-] (S8) -- node [strike out,draw,-,label=4] {} (S8OUT);
\end{tikzpicture}
\caption{\emph{DES} $f$-function}
\end{figure}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[>=latex]
\node (X) {$x$};
\node[draw=black,minimum width=6cm,minimum height=1cm,below=1cm of X] (P) {$P(x)$};
\draw [->] (X) -- node [strike out,draw,-,label=right:64] {} (P);
\coordinate[left=1.5cm of P.south] (L0out);
\coordinate[right=1.5cm of P.south] (R0out);
\node[draw=black,below=1cm of P,minimum height=1cm,minimum width=3cm,anchor=east] (L0) {$L_0$};
\draw [->] (L0out) -- node [strike out,draw,-,label=left:32] {} (L0);
\node[draw=black,right=0cm of L0,minimum height=1cm,minimum width=3cm,anchor=west] (R0) {$R_0$};
\draw [->] (R0out) -- node [strike out,draw,-,label=right:32] {} (R0);
\node[XOR,below=1cm of L0,minimum height=1cm] (XOR0) {}
edge [<-] (L0);
\coordinate[right=3cm of XOR0.center] (ANCHOR0R1) {}
edge [-] (R0);
\node[draw=black,minimum height=1cm] (f1) at ($(XOR0)!0.5!(ANCHOR0R1)$) {$f$}
edge [->] (XOR0)
edge [<-] (ANCHOR0R1);
\coordinate (K1ANCHOR) at ($(f1.east)!0.5!(f1.south east)$);
\node[right=4cm of K1ANCHOR] (k1) {$k_1$};
\draw [->] (k1) -- node [strike out,draw,-,label=48] {} (K1ANCHOR);
\coordinate[below=0.5cm of XOR0] (ANCHOR0L) {}
edge [-] (XOR0);
\coordinate[right=3cm of ANCHOR0L] (ANCHOR0R2) {}
edge [-] (ANCHOR0R1);
\node[draw=black,minimum width=3cm,minimum height=1cm,below=1cm of ANCHOR0L] (L1) {$L_1$};
\draw [->] (ANCHOR0R2) -- (L1.north);
\node[draw=black,minimum width=3cm,minimum height=1cm,right=0cm of L1] (R1) {$R_1$};
\draw [->] (ANCHOR0L) -- (R1.north);
\node[draw=black,minimum width=3cm,minimum height=1cm,below=1cm of L1] (L15) {$L_{15}$};
\node[draw=black,minimum width=3cm,minimum height=1cm,right=0cm of L15] (R15) {$R_{15}$};
\draw [dashed] ($(L1.south)!0.5!(R1.south)$) -- ($(L15.north)!0.5!(R15.north)$);
\node[XOR,below=1cm of L15,minimum height=1cm] (XOR15) {}
edge [<-] (L15);
\coordinate[right=3cm of XOR15.center] (ANCHOR15R1) {}
edge [-] (R15);
\node[draw=black,minimum height=1cm] (f15) at ($(XOR15)!0.5!(ANCHOR15R1)$) {$f$}
edge [->] (XOR15)
edge [<-] (ANCHOR15R1);
\coordinate (K16ANCHOR) at ($(f15.east)!0.5!(f15.south east)$);
\node[right=4cm of K16ANCHOR] (k16) {$k_{16}$};
\draw [->] (k16) -- node [strike out,draw,-,label=48] {} (K16ANCHOR);
\coordinate[below=0.5cm of XOR15] (ANCHOR15L) {}
edge [-] (XOR15);
\coordinate[right=3cm of ANCHOR15L] (ANCHOR15R2) {}
edge [-] (ANCHOR15R1);
\node[draw=black,minimum width=3cm,minimum height=1cm,below=1cm of ANCHOR15L] (L16) {$L_{16}$};
\draw [->] (ANCHOR15R2) -- (L16.north);
\node[draw=black,minimum width=3cm,minimum height=1cm,right=0cm of L16] (R16) {$R_{16}$};
\draw [->] (ANCHOR15L) -- (R16.north);
\node[draw=black,minimum width=3cm,minimum height=1cm,below=1cm of L16] (R161) {$R_{16}$};
\draw [->] (R16.south) -- (R161.north);
\node[draw=black,minimum width=3cm,minimum height=1cm,right=0cm of R161] (L161) {$L_{16}$};
\draw [->] (L16.south) -- (L161.north);
\coordinate (P1ANCHOR) at ($(R161)!0.5!(L161)$);
\node[draw=black,minimum width=6cm,minimum height=1cm,below=1cm of P1ANCHOR] (P1) {$P^{-1}(x)$};
\coordinate[left=1.5cm of P1.north] (R16IN);
\draw [->] (R161) -- node [strike out,draw,-,label=left:32] {} (R16IN);
\coordinate[right=1.5cm of P1.north] (L16IN);
\draw [->] (L161) -- node [strike out,draw,-,label=right:32] {} (L16IN);
\node[below=1cm of P1] (Y) {$y$};
\draw [->] (P1) -- node [strike out,draw,-,label=right:64] {} (Y);
\end{tikzpicture}
\caption{Structure of \emph{DES}}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment