summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/context/third/enigma/examples/enigma-example-latex.tex51
-rw-r--r--doc/context/third/enigma/examples/enigma-example-plain.tex47
-rw-r--r--tex/latex/enigma/enigma.sty6
-rw-r--r--tex/plain/enigma/enigma.tex19
4 files changed, 117 insertions, 6 deletions
diff --git a/doc/context/third/enigma/examples/enigma-example-latex.tex b/doc/context/third/enigma/examples/enigma-example-latex.tex
new file mode 100644
index 0000000..e3e86f7
--- /dev/null
+++ b/doc/context/third/enigma/examples/enigma-example-latex.tex
@@ -0,0 +1,51 @@
+\documentclass[a5paper]{scrartcl}
+\parindent0pt
+% \usepackage{fontspec}
+% \defaultfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}}
+%······································································%
+\usepackage {enigma}
+%%·····································································%
+%% The first machine will be used for encryption of our plain text.
+\defineenigma {encryption}
+\setupenigma {encryption} {
+ other_chars = yes,
+ day_key = B V III II 12 03 01 GI JV KZ WM PU QY AD CN ET FL,
+ rotor_setting = ben,
+}
+%%·····································································%
+%% This second machine below will be used to decrypt the string. It is
+%% initialized with exactly the same settings as the first one. The
+%% reason for this is that we can’t reuse the “encryption” machine as it
+%% will already have progressed to some later state after the
+%% encryption. Applying it on the ciphertext would yield a totally
+%% different string. Hence the need for another machine.
+\defineenigma{decryption}
+\setupenigma{decryption}{
+ other_chars = yes,
+ day_key = B V III II 12 03 01 GI JV KZ WM PU QY AD CN ET FL,
+ rotor_setting = ben,
+}
+%%·····································································%
+\begin{document}
+
+%%·····································································%
+%% Ciphertext in the PDF. Rely on the addressee to decrypt the document
+%% externally.
+\startencryption
+ Never underestimate the amount of money, time, and effort someone will expend to thwart a security system.
+\stopencryption
+
+%%·····································································%
+%% Input string generated with:
+%% mtxrun --script t-enigma \
+%% --setup="day_key=B V III II 12 03 01 GI JV KZ WM PU QY AD CN ET FL,\
+%% rotor_setting=ben,\
+%% other_chars=yes"\
+%% --text="Never underestimate the amount of money,\
+%% time, and effort someone will expend to\
+%% thwart a security system."
+\startdecryption
+ aqsnwyxgqarpuzrdktscbslaqmdhyonywxkwhcdgphvuqsspfjwhlszahygjbzmfpcpbniahvfcuradntepxsfchnn
+\stopdecryption
+%%·····································································%
+\end{document}
diff --git a/doc/context/third/enigma/examples/enigma-example-plain.tex b/doc/context/third/enigma/examples/enigma-example-plain.tex
new file mode 100644
index 0000000..d731c7d
--- /dev/null
+++ b/doc/context/third/enigma/examples/enigma-example-plain.tex
@@ -0,0 +1,47 @@
+\parindent0pt
+%······································································%
+\input {enigma}
+%%·····································································%
+%% The first machine will be used for encryption of our plain text.
+\defineenigma {encryption}
+\setupenigma {encryption} {
+ other_chars = yes,
+ day_key = B V III II 12 03 01 GI JV KZ WM PU QY AD CN ET FL,
+ rotor_setting = ben,
+}
+%%·····································································%
+%% This second machine below will be used to decrypt the string.
+\defineenigma{decryption}
+\setupenigma{decryption}{
+ other_chars = yes,
+ day_key = B V III II 12 03 01 GI JV KZ WM PU QY AD CN ET FL,
+ rotor_setting = ben,
+}
+%%·····································································%
+%% main
+%%·····································································%
+%% Ciphertext in the PDF. Rely on the addressee to decrypt the document
+%% externally.
+%%·····································································%
+%% encryption of plain text
+%%·····································································%
+\startencryption
+ Never underestimate the amount of money, time, and effort someone will expend to thwart a security system.
+\stopencryption
+
+%%·····································································%
+%% decryption of ciphertext
+%%·····································································%
+%% Input string generated with:
+%% mtxrun --script t-enigma \
+%% --setup="day_key=B V III II 12 03 01 GI JV KZ WM PU QY AD CN ET FL,\
+%% rotor_setting=ben,\
+%% other_chars=yes"\
+%% --text="Never underestimate the amount of money,\
+%% time, and effort someone will expend to\
+%% thwart a security system."
+\startdecryption
+ aqsnwyxgqarpuzrdktscbslaqmdhyonywxkwhcdgphvuqsspfjwhlszahygjbzmfpcpbniahvfcuradntepxsfchnn
+\stopdecryption
+%%·····································································%
+\bye
diff --git a/tex/latex/enigma/enigma.sty b/tex/latex/enigma/enigma.sty
index eee2cb5..e9ccee4 100644
--- a/tex/latex/enigma/enigma.sty
+++ b/tex/latex/enigma/enigma.sty
@@ -1,3 +1,7 @@
-\ProvidesPackage{enigma}[2012-02-20 21:16:13+0100 enigma]
+\ProvidesPackage
+ {enigma}
+ [2012/06/06 Enigma Document Encryption]
+\RequirePackage{luatexbase}
\input{enigma}
+\endinput
% vim:ft=tex:sw=2:ts=2:expandtab:tw=72
diff --git a/tex/plain/enigma/enigma.tex b/tex/plain/enigma/enigma.tex
index 625a38d..41d6b2d 100644
--- a/tex/plain/enigma/enigma.tex
+++ b/tex/plain/enigma/enigma.tex
@@ -1,4 +1,11 @@
-\input{luatexbase.sty}
+\expandafter\let\expandafter\x\csname ver@enigma.sty\endcsname
+\newif\ifenigmaisrunningplain
+\ifx\x\relax
+ \enigmaisrunningplaintrue
+ \input{luatexbase.sty}
+ \catcode`\@=11
+% \else latex
+\fi
\catcode`\_=11 % There’s no reason why this shouldn’t be the case.
\catcode`\!=11
%D Nice tool from luat-ini.mkiv. This really helps with those annoying
@@ -76,7 +83,7 @@
\edef\c!pre_linebreak_filter{pre_linebreak_filter}
\def\do_define_enigma#1{%
- \@EA\gdef\csname start\enigmaid\endcsname{%
+ \@EA\gdef\csname start\current_enigma_id\endcsname{%
\endgraf
\bgroup%
\directlua{%
@@ -90,7 +97,7 @@
end
}%
}%
- \@EA\gdef\csname stop\enigmaid\endcsname{%
+ \@EA\gdef\csname stop\current_enigma_id\endcsname{%
\endgraf
\directlua{
luatexbase.remove_from_callback(\!!bs\c!pre_linebreak_filter\!!es, \!!bs#1\!!es)
@@ -103,12 +110,14 @@
\def\defineenigma#1{%
\begingroup
\let\@EA\expandafter
- \edef\enigmaid{#1}%
- \@EA\do_define_enigma\@EA{\enigmaid}%
+ \edef\current_enigma_id{#1}%
+ \@EA\do_define_enigma\@EA{\current_enigma_id}%
\endgroup%
}
+
%D \stopdocsection
\catcode`\_=8 % \popcatcodes
\catcode`\!=12 % reserved according to source2e
+\ifenigmaisrunningplain\catcode`\@=12\fi
% vim:ft=tex:sw=2:ts=2:expandtab:tw=72