summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2012-02-24 16:56:17 +0100
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2012-02-24 16:56:17 +0100
commit2ad1a2fae027aa6c1f4c1259574b5aa506f833a8 (patch)
tree628924d2965d9f52b65478a42664b5dfdea86767
parent8d93a4c0ccbfb9b3fb1f17ccecdc5bf430f18154 (diff)
downloadenigma-2ad1a2fae027aa6c1f4c1259574b5aa506f833a8.tar.gz
minor fixes; [doc] example of two-pass filter
-rw-r--r--doc/context/third/enigma/enigma_manual.tex50
-rw-r--r--tex/context/third/enigma/enigma.lua4
-rw-r--r--tex/context/third/enigma/t-enigma.mkvi8
3 files changed, 53 insertions, 9 deletions
diff --git a/doc/context/third/enigma/enigma_manual.tex b/doc/context/third/enigma/enigma_manual.tex
index 281ae93..efb4fe2 100644
--- a/doc/context/third/enigma/enigma_manual.tex
+++ b/doc/context/third/enigma/enigma_manual.tex
@@ -1,4 +1,10 @@
-\startdocchapter[title=Example: Encrypted Document]
+\startdocchapter[title=Usage]
+
+\startdocsection[title=Loading the Module/Package]
+ \TODO{instuctions for plain, latex + ctx}
+\stopdocsection
+
+\startdocsection[title=Basic Functionality]
Encrypt the text of your document using the script interface. For
a start try out the settings as given in below listing.
@@ -9,11 +15,11 @@ mtxrun --script mtx-t-enigma \
day_key = B I II III 01 01 01, \
rotor_setting = xyz, \
verbose=0" \
- --text="Nobody can read this."
+ --text="Gentlemen don’t read each other’s mail, Mr. Turing\!"
\stoptyping
This will result in the thoroughly scrambled string
-\type{zdkbxwwnwkazpokvgr}.
+\type{omribshpwfrfjovkntgqgiabbkhjpxmhdztapkatwrvf}.
Then, use the same settings you encrypted the text with in your
document.
@@ -30,7 +36,7 @@ document.
\starttext
\startsecretmessage
-zdkbxwwnwkazpokvgr
+ omribshpwfrfjovkntgqgiabbkhjpxmhdztapkatwrvf
\stopsecretmessage
\stoptext
@@ -41,6 +47,42 @@ reappear.
Notice that punctuation is substituted with the letter “x” before
encryption and that spaces are omitted.
+\stopdocsection
+
+\startdocsection[title=Uses and Abuses]
+
+In \LUATEX, \identifier{callback}s may stack. This allows filtering the
+input through many enigma machines successively. For instance, in the
+following listing, two instances of the same machine are generated and
+applied.
+
+\startcontexttyping
+\usemodule[enigma] %% load the module
+\defineenigma [secretmessage] %% generate and
+\setupenigma [secretmessage] [ %% configure a machine
+ other_chars = ok,
+ day_key = B IV V II 01 01 01 AD CN ET FL GI JV KZ PU QY WX,
+ rotor_setting = foo,
+ verbose=3,
+]
+
+%% now, copy the first machine’s settings
+\defineenigma [othermessage] [secretmessage]
+
+%% here we go!
+\starttext
+
+\startothermessage %% enable machine 1
+\startsecretmessage %% enable machine 2 while no 1 is active
+Encryption equals decryption.
+\stopothermessage
+\stopsecretmessage
+
+\stoptext \endinput
+\stopcontexttyping
+
+\stopdocsection
+
\stopdocchapter
\startdocchapter[title=Acknowledgements]
diff --git a/tex/context/third/enigma/enigma.lua b/tex/context/third/enigma/enigma.lua
index f6881f6..79aadc6 100644
--- a/tex/context/third/enigma/enigma.lua
+++ b/tex/context/third/enigma/enigma.lua
@@ -578,6 +578,7 @@ ten.
["\n"] = "",
["\t"] = "",
["\v"] = "",
+ ["\\"] = "",
-- Numbers are resolved.
["0"] = "null",
["1"] = "eins",
@@ -755,6 +756,7 @@ extraction of successive characters from the sequence.
result[#result+1] = tmp
end
end
+ print(str)
machine:processed_chars()
return tableconcat(result)
end
@@ -981,6 +983,7 @@ consists of three elements:
local decode_char = encode_char -- hooray for involutory ciphers
local encode_general = function (machine, chr)
+ local chr = stringlower(chr)
local replacement = pp_substitutions[chr] or valid_char_p[chr] and chr
if not replacement then return false end
@@ -1215,7 +1218,6 @@ local new_callback = function (machine, name)
enigma.machines [name] = machine
local format_is_context_p = format_is_context_p
local cbk = function (a, _, c)
- print(name, "<<<<<<<<<<<<<<<<<<<")
local head = format_is_context_p and c or a
for n in nodetraverse(head) do
--print(node, node.id)
diff --git a/tex/context/third/enigma/t-enigma.mkvi b/tex/context/third/enigma/t-enigma.mkvi
index f6f9db7..0d2d9bf 100644
--- a/tex/context/third/enigma/t-enigma.mkvi
+++ b/tex/context/third/enigma/t-enigma.mkvi
@@ -111,12 +111,12 @@ thirddata = thirddata or { }
\ctxlua{
local enigma = thirddata.enigma
local current_args =
- enigma.parse_args([====[\detokenize{#args}]====])
- enigma.save_raw_args(current_args, [====[\currentenigmaid]====])
+ enigma.parse_args(\!!bs\detokenize{#args}\!!es)
+ enigma.save_raw_args(current_args, \!!bs\currentenigmaid\!!es)
enigma.new_callback(
enigma.new_machine(current_args,
- [====[\currentenigmaid]====]),
- [====[\currentenigmaid]====])
+ \!!bs\currentenigmaid\!!es),
+ \!!bs\currentenigmaid\!!es)
}%
}