improved indentation and whitespace for markdown code blocks

All code blocks in markdown have been intended by at least 4 spaces.

We add `--tab-stop=8` to all `pandoc(1)` executions in order to set
a better tab stop indentation, especially for tab intended code blocks.

Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26"
to "1.6 2024-03-31".

Fixed `1991/brnstnd/sorta.README.md` so that the sorta code
is code blocks.

Removed unneeded paragraph group in copyright in `inc/footer.default.html`.

Fixed excess whitespace after list Author on entry `index.html` page.

Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26"
to "1.6 2024-03-31".

Performed `make www` to perform the above and test under macOS.

TODO: Fix the problem of the initial line of code being extra intended.
TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
Landon Curt Noll committed 2024-04-01 04:48:48 -07:00
1 parent b84c27ce02
commit a996f8d2b8
734 files changed
+16723 -16963

No files matched your search

+108 -109
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
The author provided alternate code that prints the output one character at a
@@ -12,35 +12,35 @@ at once. See [Alternate code](#alternate-code) below.
## To use:
```sh
./prog
./prog
# get recode help:
./recode -h
# get recode help:
./recode -h
# general syntax for recode passing to Enigma machine:
./recode [options] | ./prog - 2>/dev/null
# general syntax for recode without passing to Enigma machine:
./recode [options]
# general syntax for recode passing to Enigma machine:
./recode [options] | ./prog - 2>/dev/null
# general syntax for recode without passing to Enigma machine:
./recode [options]
# recode prompts for settings; pass to Enigma machine:
./recode | ./prog - 2>/dev/null
# recode prompts for settings; pass to Enigma machine:
./recode | ./prog - 2>/dev/null
# recode reads from input file, prompts for settings; passed to Enigma machine:
./recode -finput | ./prog - 2>/dev/null
# recode reads from input file, prompts for settings; passed to Enigma machine:
./recode -finput | ./prog - 2>/dev/null
# recode reads config from string or file; passed to Enigma machine after
# prompting for input:
./recode -R<string|file> | ./prog - 2>/dev/null
# recode reads config from string or file; passed to Enigma machine after
# prompting for input:
./recode -R<string|file> | ./prog - 2>/dev/null
# write config to output file; passed to Enigma machine after prompting for
# input:
./recode -o<config> | ./prog - 2>/dev/null
# write config to output file; passed to Enigma machine after prompting for
# input:
./recode -o<config> | ./prog - 2>/dev/null
# pseudo-randomly select settings
./recode -r
# pseudo-randomly select settings
./recode -r
# show Enigma machine settings after selection / generation:
./recode -v
# show Enigma machine settings after selection / generation:
./recode -v
```
**NOTE**: in [recode](recode.c) no spaces between options and option arguments
@@ -50,15 +50,14 @@ are allowed.
## Try:
```sh
./try.sh
./try.sh
```
What does:
```sh
echo | ./recode
echo | ./recode -v
echo | ./recode
echo | ./recode -v
```
do?
@@ -74,14 +73,14 @@ and to make it a bit more like the real thing.
### Alternate build:
```sh
make alt
make alt
```
The default time to sleep is 400000 microseconds but you can change this by
doing:
```sh
make clobber SLEEP=600000 alt
make clobber SLEEP=600000 alt
```
to change it to 600000 microseconds. It guards against negative numbers.
@@ -95,7 +94,7 @@ Use `prog.alt` as you would `prog` above.
### Alternate try:
```sh
./try.alt.sh
./try.alt.sh
```
Notice how only the last part should use the `prog.alt`. Why? Try it and find
@@ -112,7 +111,7 @@ There is a good deal of useful documentation that is provided with this entry:
```sh
man ./enigma.1
man ./enigma.1
```
@@ -253,7 +252,7 @@ the result (after finishing the enciphering).
If you run it like:
```sh
./prog -
./prog -
```
It will prompt you for the settings of the machine (example below).
@@ -285,30 +284,30 @@ code](https://en.wikipedia.org/wiki/Morse_code) that I referred to earlier:
```sh
$ ./prog -
Ring 1: 3
Setting 1: I
Position 1: O
Ring 2: 1
Setting 2: C
Position 2: C
Ring 3: 5
Setting 3: C
Position 3: Z
Reflector: 2
Plugboard pair 1: CO
Plugboard pair 2: DE
Plugboard pair 3: SN
Plugboard pair 4: XY
Plugboard pair 5: MS
Plugboard pair 6: AT
Plugboard pair 7: VF
Plugboard pair 8: UR
Plugboard pair 9: KL
Plugboard pair 10: BJ
IOCCC
^D
CFDRG
$ ./prog -
Ring 1: 3
Setting 1: I
Position 1: O
Ring 2: 1
Setting 2: C
Position 2: C
Ring 3: 5
Setting 3: C
Position 3: Z
Reflector: 2
Plugboard pair 1: CO
Plugboard pair 2: DE
Plugboard pair 3: SN
Plugboard pair 4: XY
Plugboard pair 5: MS
Plugboard pair 6: AT
Plugboard pair 7: VF
Plugboard pair 8: UR
Plugboard pair 9: KL
Plugboard pair 10: BJ
IOCCC
^D
CFDRG
```
Notice that all output except the deciphered/enciphered text is sent to stdout.
@@ -319,9 +318,9 @@ default settings; as the judges suggest this invocation I will not show it here.
But you can also type it out like this:
```sh
$ ./prog
IOCCC
UUMMX
$ ./prog
IOCCC
UUMMX
```
The IOCCC comes from stdin; the `UUMMX` is written to stdout.
@@ -330,7 +329,7 @@ If I compile the 2014 entry and copy it to my local directory as
`vik` I might do:
```sh
$ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -
$ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -
```
And you would hear [Morse code](https://en.wikipedia.org/wiki/Morse_code) of the
@@ -342,30 +341,30 @@ For example I can use the syntax provided in the winning remarks along with my
entry to write it to a file. Say:
```sh
$ echo TEST|./prog |./vik > test.raw
$ ./vik e < test.raw | ./prog
LEST
$ echo TEST|./prog |./vik > test.raw
$ ./vik e < test.raw | ./prog
LEST
```
Why did that happen? This shows more details:
```sh
$ ./vik e < test.raw
SCWV
$ ./vik e < test.raw
SCWV
```
However as can be seen the first char is wrong:
```sh
$ echo TEST|./prog
KCWV
$ echo TEST|./prog
KCWV
```
And piping the original output to my entry itself you get the original input:
```sh
$ echo TEST | ./prog | ./prog
TEST
$ echo TEST | ./prog | ./prog
TEST
```
I'm not sure what causes that or if there's a way to fix it but that's the
@@ -374,19 +373,19 @@ idea anyway. Neither do I know if the original transcoding is correct.
What if I use the input string `LEST` instead? In that case it worked fine:
```sh
$ echo LEST | ./prog | ./vik > lest.raw
$ ./vik e < lest.raw | ./prog
LEST
$ echo LEST | ./prog | ./vik > lest.raw
$ ./vik e < lest.raw | ./prog
LEST
```
But there's one obvious question, right? Let's try the most important one:
```sh
$ echo IOCCC | ./prog | ./vik > ioccc.raw
$ ./vik e < ioccc.raw
UUMMX
$ ./vik e < ioccc.raw | ./prog
IOCCC
$ echo IOCCC | ./prog | ./vik > ioccc.raw
$ ./vik e < ioccc.raw
UUMMX
$ ./vik e < ioccc.raw | ./prog
IOCCC
```
Phew! The program redeemed itself after the test failure! :)
@@ -398,8 +397,8 @@ too. Notice also how it showed the same output that my program gave it - `UUMMX`
What about the other [Morse code entry](../../1998/dorssel/dorssel.c)?
```sh
$ echo IOCCC | ./prog | ./dorssel
..- ..- -- -- -..-
$ echo IOCCC | ./prog | ./dorssel
..- ..- -- -- -..-
```
### <a name="recode" href="#toc">The recode.c configurator</a>
@@ -443,26 +442,26 @@ automatic (e.g. via the [recode](recode.c) program) input. This does mean that
something like the following can happen:
```sh
$ ./prog -
Ring 1: 1AB
Setting 1: Position 1: Ring 2: 2CD
Setting 2: Position 2: Ring 3: 3
Setting 3: A
Position 3: B
Reflector: 1A
Plugboard pair 1: BC
Plugboard pair 2: ..
Plugboard pair 3: ..
Plugboard pair 4: DE
Plugboard pair 5: FG
Plugboard pair 6: HI
Plugboard pair 7: JK
Plugboard pair 8: LM
Plugboard pair 9: NO
Plugboard pair 10: PQ
IOCCC
WD
SIRDK
$ ./prog -
Ring 1: 1AB
Setting 1: Position 1: Ring 2: 2CD
Setting 2: Position 2: Ring 3: 3
Setting 3: A
Position 3: B
Reflector: 1A
Plugboard pair 1: BC
Plugboard pair 2: ..
Plugboard pair 3: ..
Plugboard pair 4: DE
Plugboard pair 5: FG
Plugboard pair 6: HI
Plugboard pair 7: JK
Plugboard pair 8: LM
Plugboard pair 9: NO
Plugboard pair 10: PQ
IOCCC
WD
SIRDK
```
First of all: what is that `WD`? I didn't type that but it showed up hitting
@@ -506,10 +505,10 @@ later on?). This might become even more useful after the challenge is accepted,
accomplished and made use of! :)
```sh
$ echo ABC | ./prog
GYM
$ echo ABC | ./prog | ./prog
ABC
$ echo ABC | ./prog
GYM
$ echo ABC | ./prog | ./prog
ABC
```
### <a name="layout" href="#toc">On the source code layout</a>
@@ -554,13 +553,13 @@ that proof that it's obfuscated itself?! :) Silliness aside [obfuscation.txt][]
has some of the ways I think this entry is obfuscated. To decipher try:
```sh
./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md
./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md
```
To encipher:
```sh
./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt
./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt
```
The file [obfuscation.key][] is the key to decipher/encipher
@@ -579,8 +578,8 @@ As for the [obfuscation.key][] file if you observe the contents you'll find the
word `OBFUSCATION`:
```
2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
OB FU SC ATION
2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
OB FU SC ATION
```
### <a name="bugs" href="#toc">Bugs, limitations, differences from the real Enigma machines and general notes</a>
@@ -763,8 +762,8 @@ I, II and III and the starting positions at B, B and C respectively (as in left,
centre, right). To do this click the button at the top right that looks like:
```
o->
<-o
o->
<-o
```
and then select the rotors. Next click the button again at the left of the
@@ -786,7 +785,7 @@ Going back to the configuring the online simulator try inputting the text IOCCC
and you'll see the resulting text being:
```
UUMMX
UUMMX
```
Which is exactly as my entry shows! So at least for the starting position `BBC`
+109 -110
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,62 +141,62 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<p>The author provided alternate code that prints the output one character at a
time to make it a bit more like the real thing in that it isn’t dumped out all
at once. See <a href="#alternate-code">Alternate code</a> below.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># get recode help:</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-h</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="co"># get recode help:</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-h</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="co"># general syntax for recode passing to Enigma machine:</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="co"># general syntax for recode without passing to Enigma machine:</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="co"># general syntax for recode passing to Enigma machine:</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="co"># general syntax for recode without passing to Enigma machine:</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="co"># recode prompts for settings; pass to Enigma machine:</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># recode prompts for settings; pass to Enigma machine:</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="co"># recode reads from input file, prompts for settings; passed to Enigma machine:</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-finput</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="co"># recode reads from input file, prompts for settings; passed to Enigma machine:</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-finput</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="co"># recode reads config from string or file; passed to Enigma machine after</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="co"># prompting for input:</span></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-R</span><span class="op">&lt;</span>string<span class="kw">|</span><span class="fu">file</span><span class="op">&gt;</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># recode reads config from string or file; passed to Enigma machine after</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> <span class="co"># prompting for input:</span></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-R</span><span class="op">&lt;</span>string<span class="kw">|</span><span class="fu">file</span><span class="op">&gt;</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a><span class="co"># write config to output file; passed to Enigma machine after prompting for</span></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a><span class="co"># input:</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-o</span><span class="op">&lt;</span>config<span class="op">&gt;</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a> <span class="co"># write config to output file; passed to Enigma machine after prompting for</span></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a> <span class="co"># input:</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-o</span><span class="op">&lt;</span>config<span class="op">&gt;</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a><span class="co"># pseudo-randomly select settings</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-r</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a> <span class="co"># pseudo-randomly select settings</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-r</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a><span class="co"># show Enigma machine settings after selection / generation:</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-v</span></span></code></pre></div>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a> <span class="co"># show Enigma machine settings after selection / generation:</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-v</span></span></code></pre></div>
<p><strong>NOTE</strong>: in <a href="recode.c">recode</a> no spaces between options and option arguments
are allowed.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<p>What does:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-v</span></span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-v</span></span></code></pre></div>
<p>do?</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version, <a href="prog.alt.c">prog.alt.c</a>, writes a character at a time, sleeping
after each character, so that one can read it more easily (for longer output)
and to make it a bit more like the real thing.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<p>The default time to sleep is 400000 microseconds but you can change this by
doing:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber SLEEP=600000 alt</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber SLEEP=600000 alt</span></code></pre></div>
<p>to change it to 600000 microseconds. It guards against negative numbers.</p>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span></code></pre></div>
<p>Notice how only the last part should use the <code>prog.alt</code>. Why? Try it and find
out! Can you figure out why this works this way?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -206,7 +205,7 @@ out! Can you figure out why this works this way?</p>
<ul>
<li><a href="enigma.1">enigma.1</a> - A useful man page for this entry. To render, try:</li>
</ul>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">man</span> ./enigma.1</span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">man</span> ./enigma.1</span></code></pre></div>
<ul>
<li><a href="recode.html">recode.html</a> (or <a href="recode.html">recode.html</a> if reading on GitHub)
<ul>
@@ -318,7 +317,7 @@ leave this in for historical purposes.</p>
for input (end with EOF). At that point it’ll process the input string and print
the result (after finishing the enciphering).</p>
<p>If you run it like:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="at">-</span></span></code></pre></div>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="at">-</span></span></code></pre></div>
<p>It will prompt you for the settings of the machine (example below).</p>
<p>The first group is in the order of
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">rotor</a> (number),
@@ -339,78 +338,78 @@ on GitHub see <a href="chocolate-cake.html">here</a>) though one might need a di
of exercise after taking up the challenge! :-) These however show the general
program as well as how to use the two winning entries of the <a href="https://en.wikipedia.org/wiki/Morse_code">Morse
code</a> that I referred to earlier:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog <span class="at">-</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: 3</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 1: I</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Position</span> 1: O</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 2: 1</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 2: C</span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a><span class="ex">Position</span> 2: C</span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 3: 5</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 3: C</span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a><span class="ex">Position</span> 3: Z</span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span> 2</span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 1: CO</span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 2: DE</span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 3: SN</span>
<span id="cb10-15"><a href="#cb10-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 4: XY</span>
<span id="cb10-16"><a href="#cb10-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 5: MS</span>
<span id="cb10-17"><a href="#cb10-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 6: AT</span>
<span id="cb10-18"><a href="#cb10-18" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 7: VF</span>
<span id="cb10-19"><a href="#cb10-19" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 8: UR</span>
<span id="cb10-20"><a href="#cb10-20" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 9: KL</span>
<span id="cb10-21"><a href="#cb10-21" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 10: BJ</span>
<span id="cb10-22"><a href="#cb10-22" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb10-23"><a href="#cb10-23" aria-hidden="true" tabindex="-1"></a><span class="ex">^D</span></span>
<span id="cb10-24"><a href="#cb10-24" aria-hidden="true" tabindex="-1"></a><span class="ex">CFDRG</span></span></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog <span class="at">-</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 1: 3</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 1: I</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">Position</span> 1: O</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 2: 1</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 2: C</span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">Position</span> 2: C</span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 3: 5</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 3: C</span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">Position</span> 3: Z</span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">Reflector:</span> 2</span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 1: CO</span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 2: DE</span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 3: SN</span>
<span id="cb10-15"><a href="#cb10-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 4: XY</span>
<span id="cb10-16"><a href="#cb10-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 5: MS</span>
<span id="cb10-17"><a href="#cb10-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 6: AT</span>
<span id="cb10-18"><a href="#cb10-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 7: VF</span>
<span id="cb10-19"><a href="#cb10-19" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 8: UR</span>
<span id="cb10-20"><a href="#cb10-20" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 9: KL</span>
<span id="cb10-21"><a href="#cb10-21" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 10: BJ</span>
<span id="cb10-22"><a href="#cb10-22" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span>
<span id="cb10-23"><a href="#cb10-23" aria-hidden="true" tabindex="-1"></a> <span class="ex">^D</span></span>
<span id="cb10-24"><a href="#cb10-24" aria-hidden="true" tabindex="-1"></a> <span class="ex">CFDRG</span></span></code></pre></div>
<p>Notice that all output except the deciphered/enciphered text is sent to stdout.</p>
<p>If I didn’t specify the <code>-</code> by e.g. <code>echo IOCCC | ./prog</code> then it will use the
default settings; as the judges suggest this invocation I will not show it here.</p>
<p>But you can also type it out like this:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="ex">UUMMX</span></span></code></pre></div>
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">UUMMX</span></span></code></pre></div>
<p>The IOCCC comes from stdin; the <code>UUMMX</code> is written to stdout.</p>
<p>If I compile the 2014 entry and copy it to my local directory as
<code>vik</code> I might do:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo TEST<span class="kw">|</span><span class="ex">./prog</span> <span class="kw">|</span><span class="ex">./vik</span> <span class="kw">|</span> <span class="ex">mplayer</span> <span class="at">-demuxer</span> rawaudio <span class="at">-</span></span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo TEST<span class="kw">|</span><span class="ex">./prog</span> <span class="kw">|</span><span class="ex">./vik</span> <span class="kw">|</span> <span class="ex">mplayer</span> <span class="at">-demuxer</span> rawaudio <span class="at">-</span></span></code></pre></div>
<p>And you would hear <a href="https://en.wikipedia.org/wiki/Morse_code">Morse code</a> of the
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">Enigma</a> output
of ‘TEST’ (i.e. <code>KCWV</code>)! Or perhaps not in this case. I’m not sure: I discovered
a bug in that entry (Fedora, CentOS and macOS all affected).</p>
<p>For example I can use the syntax provided in the winning remarks along with my
entry to write it to a file. Say:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo TEST<span class="kw">|</span><span class="ex">./prog</span> <span class="kw">|</span><span class="ex">./vik</span> <span class="op">&gt;</span> test.raw</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./vik e <span class="op">&lt;</span> test.raw <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">LEST</span></span></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo TEST<span class="kw">|</span><span class="ex">./prog</span> <span class="kw">|</span><span class="ex">./vik</span> <span class="op">&gt;</span> test.raw</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./vik e <span class="op">&lt;</span> test.raw <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">LEST</span></span></code></pre></div>
<p>Why did that happen? This shows more details:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./vik e <span class="op">&lt;</span> test.raw</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="ex">SCWV</span></span></code></pre></div>
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./vik e <span class="op">&lt;</span> test.raw</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">SCWV</span></span></code></pre></div>
<p>However as can be seen the first char is wrong:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo TEST<span class="kw">|</span><span class="ex">./prog</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">KCWV</span></span></code></pre></div>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo TEST<span class="kw">|</span><span class="ex">./prog</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">KCWV</span></span></code></pre></div>
<p>And piping the original output to my entry itself you get the original input:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo TEST <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="ex">TEST</span></span></code></pre></div>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo TEST <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">TEST</span></span></code></pre></div>
<p>I’m not sure what causes that or if there’s a way to fix it but that’s the
idea anyway. Neither do I know if the original transcoding is correct.</p>
<p>What if I use the input string <code>LEST</code> instead? In that case it worked fine:</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo LEST <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./vik</span> <span class="op">&gt;</span> lest.raw</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./vik e <span class="op">&lt;</span> lest.raw <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a><span class="ex">LEST</span></span></code></pre></div>
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo LEST <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./vik</span> <span class="op">&gt;</span> lest.raw</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./vik e <span class="op">&lt;</span> lest.raw <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">LEST</span></span></code></pre></div>
<p>But there’s one obvious question, right? Let’s try the most important one:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./vik</span> <span class="op">&gt;</span> ioccc.raw</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./vik e <span class="op">&lt;</span> ioccc.raw</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="ex">UUMMX</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./vik e <span class="op">&lt;</span> ioccc.raw <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./vik</span> <span class="op">&gt;</span> ioccc.raw</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./vik e <span class="op">&lt;</span> ioccc.raw</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">UUMMX</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./vik e <span class="op">&lt;</span> ioccc.raw <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span></code></pre></div>
<p>Phew! The program redeemed itself after the test failure! :)</p>
<p>(Technically above it didn’t print a newline after the output and this is how it
is with some of the things I pasted in the other file and maybe others here
too. Notice also how it showed the same output that my program gave it - <code>UUMMX</code>.)</p>
<p>What about the other <a href="../../1998/dorssel/dorssel.c">Morse code entry</a>?</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">..-</span> ..- <span class="at">--</span> <span class="at">--</span> <span class="at">-..-</span></span></code></pre></div>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">..-</span> ..- <span class="at">--</span> <span class="at">--</span> <span class="at">-..-</span></span></code></pre></div>
<h3 id="the-recode.c-configurator"><a name="recode" href="#toc">The recode.c configurator</a></h3>
<p>I have included a supplementary program <a href="recode.c">recode.c</a> that can do a number of
things which acts as a kind of wrapper and configurator to my entry. By default
@@ -441,26 +440,26 @@ make it more flexible by a wrapper program.</p>
<p>The parser is in a sense rather rudimentary but allows for both interactive and
automatic (e.g. via the <a href="recode.c">recode</a> program) input. This does mean that
something like the following can happen:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog <span class="at">-</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: 1AB</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 1: Position 1: Ring 2: 2CD</span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 2: Position 2: Ring 3: 3</span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 3: A</span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Position</span> 3: B</span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span> 1A</span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 1: BC</span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 2: ..</span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 3: ..</span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 4: DE</span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 5: FG</span>
<span id="cb20-13"><a href="#cb20-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 6: HI</span>
<span id="cb20-14"><a href="#cb20-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 7: JK</span>
<span id="cb20-15"><a href="#cb20-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 8: LM</span>
<span id="cb20-16"><a href="#cb20-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 9: NO</span>
<span id="cb20-17"><a href="#cb20-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair 10: PQ</span>
<span id="cb20-18"><a href="#cb20-18" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb20-19"><a href="#cb20-19" aria-hidden="true" tabindex="-1"></a><span class="ex">WD</span></span>
<span id="cb20-20"><a href="#cb20-20" aria-hidden="true" tabindex="-1"></a><span class="ex">SIRDK</span></span></code></pre></div>
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog <span class="at">-</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 1: 1AB</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 1: Position 1: Ring 2: 2CD</span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 2: Position 2: Ring 3: 3</span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 3: A</span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">Position</span> 3: B</span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">Reflector:</span> 1A</span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 1: BC</span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 2: ..</span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 3: ..</span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 4: DE</span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 5: FG</span>
<span id="cb20-13"><a href="#cb20-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 6: HI</span>
<span id="cb20-14"><a href="#cb20-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 7: JK</span>
<span id="cb20-15"><a href="#cb20-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 8: LM</span>
<span id="cb20-16"><a href="#cb20-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 9: NO</span>
<span id="cb20-17"><a href="#cb20-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair 10: PQ</span>
<span id="cb20-18"><a href="#cb20-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span>
<span id="cb20-19"><a href="#cb20-19" aria-hidden="true" tabindex="-1"></a> <span class="ex">WD</span></span>
<span id="cb20-20"><a href="#cb20-20" aria-hidden="true" tabindex="-1"></a> <span class="ex">SIRDK</span></span></code></pre></div>
<p>First of all: what is that <code>WD</code>? I didn’t type that but it showed up hitting
<code>ctrl-d</code> to end input.</p>
<p>If everything is input correctly it would show nothing except the actual
@@ -494,10 +493,10 @@ GitHub).</p>
should help you remember (though not at this time in our world it might help you
later on?). This might become even more useful after the challenge is accepted,
accomplished and made use of! :)</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo ABC <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="ex">GYM</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo ABC <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a><span class="ex">ABC</span></span></code></pre></div>
<div class="sourceCode" id="cb21"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo ABC <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">GYM</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo ABC <span class="kw">|</span> <span class="ex">./prog</span> <span class="kw">|</span> <span class="ex">./prog</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">ABC</span></span></code></pre></div>
<h3 id="on-the-source-code-layout"><a name="layout" href="#toc">On the source code layout</a></h3>
<p>The layout of <a href="recode.c">recode.c</a> isn’t too significant (but see below) but I want to
mention <a href="prog.c">prog.c</a> especially:</p>
@@ -525,9 +524,9 @@ ended his life. (I later made a bug fix but I consider this inconsequential).</p
<p>It’s an <a href="https://en.wikipedia.org/wiki/Enigma_machine">Enigma machine</a> simulator! Isn’t
that proof that it’s obfuscated itself?! :) Silliness aside <a href="obfuscation.txt">obfuscation.txt</a>
has some of the ways I think this entry is obfuscated. To decipher try:</p>
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-Robfuscation.key</span> <span class="at">-fobfuscation.txt</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> obfuscation.md</span></code></pre></div>
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-Robfuscation.key</span> <span class="at">-fobfuscation.txt</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> obfuscation.md</span></code></pre></div>
<p>To encipher:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-Robfuscation.key</span> <span class="at">-fobfuscation.md</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> obfuscation.txt</span></code></pre></div>
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-Robfuscation.key</span> <span class="at">-fobfuscation.md</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> obfuscation.txt</span></code></pre></div>
<p>The file <a href="obfuscation.key">obfuscation.key</a> is the key to decipher/encipher
<a href="obfuscation.txt">obfuscation.txt</a>.</p>
<p>For the lazy <a href="obfuscation.html">obfuscation.html</a> has the deciphered version. I am afraid I’m not
@@ -540,8 +539,8 @@ GitHub), not enciphered, one might just go there instead. Still it’s a fun way
to explore this entry.</p>
<p>As for the <a href="obfuscation.key">obfuscation.key</a> file if you observe the contents you’ll find the
word <code>OBFUSCATION</code>:</p>
<pre><code>2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
OB FU SC ATION</code></pre>
<pre><code> 2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
OB FU SC ATION</code></pre>
<h3 id="bugs-limitations-differences-from-the-real-enigma-machines-and-general-notes"><a name="bugs" href="#toc">Bugs, limitations, differences from the real Enigma machines and general notes</a></h3>
<p>Ways that my simulator differs from the real thing. Not all of these are bugs
and some could be considered features; others are just differences.</p>
@@ -688,8 +687,8 @@ simulator make sure to use
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm#Rotors">Rotors</a>
I, II and III and the starting positions at B, B and C respectively (as in left,
centre, right). To do this click the button at the top right that looks like:</p>
<pre><code>o-&gt;
&lt;-o</code></pre>
<pre><code> o-&gt;
&lt;-o</code></pre>
<p>and then select the rotors. Next click the button again at the left of the
rotor selection ‘screen’. Then use the arrow buttons above each rotor to set
from left to right B, B and C. After this you can type your message in the input
@@ -704,7 +703,7 @@ determine if the ring settings being different from <code>ABC</code> would cause
(this is the thing I mention I’m uncertain about in the bugs section).</p>
<p>Going back to the configuring the online simulator try inputting the text IOCCC
and you’ll see the resulting text being:</p>
<pre><code>UUMMX</code></pre>
<pre><code> UUMMX</code></pre>
<p>Which is exactly as my entry shows! So at least for the starting position <code>BBC</code>
and an empty <a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard</a>
and the other defaults in my entry (which appear to be consistent with the
+75 -63
View File
@@ -138,40 +138,43 @@ there is an aesthetic appeal to my eyes too).</p></li>
(including what was originally two arrays plus some additional ints).</p></li>
<li><p>Negative pointer offsets. This include calculated offsets into the huge
Y&lt;:19:&gt;&lt;:27:&gt; but it’s not the only example. Here the compound literal of 13
ints:</p>
<pre><code>int *z=(int[13]) { 0 } , *e, *g;</code></pre>
ints:</p></li>
</ul>
<div class="sourceCode" id="cb1"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> <span class="op">*</span>z<span class="op">=(</span><span class="dt">int</span><span class="op">[</span><span class="dv">13</span><span class="op">])</span> <span class="op">{</span> <span class="dv">0</span> <span class="op">}</span> <span class="op">,</span> <span class="op">*</span>e<span class="op">,</span> <span class="op">*</span>g<span class="op">;</span></span></code></pre></div>
<p>Then in main:</p>
<pre><code>e = z + 10;
g = e + 1;
for (j=-3; j &lt; 0; ++j)
e&lt;:j:&gt; = j+3;</code></pre>
<div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> e <span class="op">=</span> z <span class="op">+</span> <span class="dv">10</span><span class="op">;</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> g <span class="op">=</span> e <span class="op">+</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> <span class="op">(</span>j<span class="op">=-</span><span class="dv">3</span><span class="op">;</span> j <span class="op">&lt;</span> <span class="dv">0</span><span class="op">;</span> <span class="op">++</span>j<span class="op">)</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> e<span class="op">&lt;:</span>j<span class="op">:&gt;</span> <span class="op">=</span> j<span class="op">+</span><span class="dv">3</span><span class="op">;</span></span></code></pre></div>
<p>Which I think is more confusing: when one is iterating an array you don’t
expect to start out with index &lt; 0 but to then compare that that index &lt; 0
and increment until 0 along with setting the value of the array to j + 3 is
more confusing still. There are at least two other ways that are much easier
to read that could accomplish the same thing. It continues on:</p>
<pre><code>/* ... */
e&lt;:i-3:&gt; = (j &lt; 1 ? 1 : (j &gt; 5 ? 5 : j))-1;</code></pre></li>
<li><p>Observe these two functions:</p>
<pre><code>void w(char *s, int k, int v)
{
for(e&lt;:2:&gt; = 0; s&lt;:*P:&gt;; ++e&lt;:2:&gt;)
{
v = s&lt;:e&lt;:2:&gt;:&gt;;
if(v &gt; 64 &amp;&amp; v &lt; 91)
s&lt;:e&lt;:2:&gt;:&gt; = (((v - 65 + k) % 26) + 65);
}
}
void Q(void)
{
for(*g = 0; *g &lt; 3; ++*g)
{
*Y&lt;:16+e&lt;:1:&gt;:&gt;=S&lt;:e&lt;:e&lt;:1:&gt;-3:&gt;:&gt;;
R&lt;:e&lt;:1:&gt;:&gt;=Y&lt;:e&lt;:-3+e&lt;:1:&gt;:&gt;:&gt;;
w(R[*g],*(e+e&lt;:1:&gt;-6)=q(Y&lt;:8:&gt;,*Y&lt;:7:&gt;),*g);
}
}</code></pre>
<div class="sourceCode" id="cb3"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="co">/* ... */</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> e<span class="op">&lt;:</span>i<span class="op">-</span><span class="dv">3</span><span class="op">:&gt;</span> <span class="op">=</span> <span class="op">(</span>j <span class="op">&lt;</span> <span class="dv">1</span> <span class="op">?</span> <span class="dv">1</span> <span class="op">:</span> <span class="op">(</span>j <span class="op">&gt;</span> <span class="dv">5</span> <span class="op">?</span> <span class="dv">5</span> <span class="op">:</span> j<span class="op">))-</span><span class="dv">1</span><span class="op">;</span></span></code></pre></div>
<ul>
<li>Observe these two functions:</li>
</ul>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> w<span class="op">(</span><span class="dt">char</span> <span class="op">*</span>s<span class="op">,</span> <span class="dt">int</span> k<span class="op">,</span> <span class="dt">int</span> v<span class="op">)</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(</span>e<span class="op">&lt;:</span><span class="dv">2</span><span class="op">:&gt;</span> <span class="op">=</span> <span class="dv">0</span><span class="op">;</span> s<span class="op">&lt;:*</span>P<span class="op">:&gt;;</span> <span class="op">++</span>e<span class="op">&lt;:</span><span class="dv">2</span><span class="op">:&gt;)</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> v <span class="op">=</span> s<span class="op">&lt;:</span>e<span class="op">&lt;:</span><span class="dv">2</span><span class="op">:&gt;:&gt;;</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span><span class="op">(</span>v <span class="op">&gt;</span> <span class="dv">64</span> <span class="op">&amp;&amp;</span> v <span class="op">&lt;</span> <span class="dv">91</span><span class="op">)</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> s<span class="op">&lt;:</span>e<span class="op">&lt;:</span><span class="dv">2</span><span class="op">:&gt;:&gt;</span> <span class="op">=</span> <span class="op">(((</span>v <span class="op">-</span> <span class="dv">65</span> <span class="op">+</span> k<span class="op">)</span> <span class="op">%</span> <span class="dv">26</span><span class="op">)</span> <span class="op">+</span> <span class="dv">65</span><span class="op">);</span></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> Q<span class="op">(</span><span class="dt">void</span><span class="op">)</span></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(*</span>g <span class="op">=</span> <span class="dv">0</span><span class="op">;</span> <span class="op">*</span>g <span class="op">&lt;</span> <span class="dv">3</span><span class="op">;</span> <span class="op">++*</span>g<span class="op">)</span></span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>Y<span class="op">&lt;:</span><span class="dv">16</span><span class="op">+</span>e<span class="op">&lt;:</span><span class="dv">1</span><span class="op">:&gt;:&gt;=</span>S<span class="op">&lt;:</span>e<span class="op">&lt;:</span>e<span class="op">&lt;:</span><span class="dv">1</span><span class="op">:&gt;-</span><span class="dv">3</span><span class="op">:&gt;:&gt;;</span></span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> R<span class="op">&lt;:</span>e<span class="op">&lt;:</span><span class="dv">1</span><span class="op">:&gt;:&gt;=</span>Y<span class="op">&lt;:</span>e<span class="op">&lt;:-</span><span class="dv">3</span><span class="op">+</span>e<span class="op">&lt;:</span><span class="dv">1</span><span class="op">:&gt;:&gt;:&gt;;</span></span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a> w<span class="op">(</span>R<span class="op">[*</span>g<span class="op">],*(</span>e<span class="op">+</span>e<span class="op">&lt;:</span><span class="dv">1</span><span class="op">:&gt;-</span><span class="dv">6</span><span class="op">)=</span>q<span class="op">(</span>Y<span class="op">&lt;:</span><span class="dv">8</span><span class="op">:&gt;,*</span>Y<span class="op">&lt;:</span><span class="dv">7</span><span class="op">:&gt;),*</span>g<span class="op">);</span></span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<p>First of all: why do I set <code>e[2]</code> to 0 and increment it for each pass in the
loop, but then the condition for the loop is <code>s[*P]</code>?</p>
<p>Second notice the many references to e[1] (as e[1] and <em>g). This variable (pointing
@@ -189,40 +192,47 @@ unspecified I changed it to what it is now. Anyway:</p>
<p>You can also see that I use the value of e[1]-3 as the index of S[e] (so
S[e[e[1]-3]]) (I think I said that right; I honestly don’t know now because
there is such major array and offset abuse. The entire prog.c is riddled
with offset abuses.).</p></li>
<li><p>If you observe that above the compound literal <code>z</code> is of size 13 but I point
with offset abuses.).</p>
<ul>
<li>If you observe that above the compound literal <code>z</code> is of size 13 but I point
<code>e</code> to be <code>z + 10</code>. Why? Twofold: (1) I decided to make use of one of them as a
temporary variable instead of a regular int in the function (so make it global);
and (2) I didn’t want to risk changing all the offsets: thus I just made that
address <code>e[1]</code>. Thus I also have:</p>
<pre><code>for (*g = 0 ; *g &lt; 10; ++*g)
{
r&lt;:-2:&gt; = Y&lt;:14:&gt;&lt;:*(e+1):&gt;; r&lt;:-3:&gt; = Y&lt;:15:&gt;&lt;:1&lt;:e:&gt;:&gt;;
if (r&lt;:-3:&gt; &amp;&amp; r&lt;:-2:&gt; == r&lt;:-1:&gt;)
return r&lt;:-3:&gt;;
if (r&lt;:-2:&gt; &amp;&amp; r&lt;:-3:&gt; == r&lt;:-1:&gt;)
return r&lt;:-2:&gt;;
}</code></pre>
address <code>e[1]</code>. Thus I also have:</li>
</ul>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> <span class="op">(*</span>g <span class="op">=</span> <span class="dv">0</span> <span class="op">;</span> <span class="op">*</span>g <span class="op">&lt;</span> <span class="dv">10</span><span class="op">;</span> <span class="op">++*</span>g<span class="op">)</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> r<span class="op">&lt;:-</span><span class="dv">2</span><span class="op">:&gt;</span> <span class="op">=</span> Y<span class="op">&lt;:</span><span class="dv">14</span><span class="op">:&gt;&lt;:*(</span>e<span class="op">+</span><span class="dv">1</span><span class="op">):&gt;;</span> r<span class="op">&lt;:-</span><span class="dv">3</span><span class="op">:&gt;</span> <span class="op">=</span> Y<span class="op">&lt;:</span><span class="dv">15</span><span class="op">:&gt;&lt;:</span><span class="dv">1</span><span class="op">&lt;:</span>e<span class="op">:&gt;:&gt;;</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>r<span class="op">&lt;:-</span><span class="dv">3</span><span class="op">:&gt;</span> <span class="op">&amp;&amp;</span> r<span class="op">&lt;:-</span><span class="dv">2</span><span class="op">:&gt;</span> <span class="op">==</span> r<span class="op">&lt;:-</span><span class="dv">1</span><span class="op">:&gt;)</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> r<span class="op">&lt;:-</span><span class="dv">3</span><span class="op">:&gt;;</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>r<span class="op">&lt;:-</span><span class="dv">2</span><span class="op">:&gt;</span> <span class="op">&amp;&amp;</span> r<span class="op">&lt;:-</span><span class="dv">3</span><span class="op">:&gt;</span> <span class="op">==</span> r<span class="op">&lt;:-</span><span class="dv">1</span><span class="op">:&gt;)</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> r<span class="op">&lt;:-</span><span class="dv">2</span><span class="op">:&gt;;</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<p>This <code>e[1]</code> of course is the same as <code>*g</code> as above and as you can see has
multiple dimensions (that is the reference to Y does) too (and this is also
strewn about the code). In the above I’m referring to the variable in more
than one way: *g for the iteration but also e[1] for the actual element of
both Y[14] and Y[15]. I also happen to use S (via r which points to S + 10)
which I use as the two chars to compare (this is the plugboard function).</p></li>
<li><p>The above function Z() takes a <code>char x</code> but you won’t notice it being used
at all. Why? In fact I call it like so:</p>
<pre><code> k = Z(r&lt;:-1:&gt;=k);</code></pre>
which I use as the two chars to compare (this is the plugboard function).</p>
<ul>
<li>The above function Z() takes a <code>char x</code> but you won’t notice it being used
at all. Why? In fact I call it like so:</li>
</ul>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> k <span class="op">=</span> Z<span class="op">(</span>r<span class="op">&lt;:-</span><span class="dv">1</span><span class="op">:&gt;=</span>k<span class="op">);</span></span></code></pre></div>
<p>The char is just used as a way to be able to call the function and assign to
the proper variable at the same time: in the function Z I don’t care about x
because it’s the same value as r[-1] (which I do care about). Why is it
attached to S? Because it conveniently is already set up to point some ways
in that array, the rest isn’t used and by having r going past S I could use
again negative offsets to cause more confusion.</p></li>
<li><p>Although this is clearly already shown in the above there are other ways I
again negative offsets to cause more confusion.</p>
<ul>
<li>Although this is clearly already shown in the above there are other ways I
refer to the same variable in more than one way (or in some cases maybe more
correct to say ‘same location’). In the Z() function for example:</p>
<pre><code> r&lt;:-2:&gt; = Y&lt;:14:&gt;&lt;:*(e+1):&gt;; r&lt;:-3:&gt; = Y&lt;:15:&gt;&lt;:1&lt;:e:&gt;:&gt;;</code></pre>
<p>I refer to e[1] as both: *(e+1) and 1[e].</p></li>
correct to say ‘same location’). In the Z() function for example:</li>
</ul>
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> r<span class="op">&lt;:-</span><span class="dv">2</span><span class="op">:&gt;</span> <span class="op">=</span> Y<span class="op">&lt;:</span><span class="dv">14</span><span class="op">:&gt;&lt;:*(</span>e<span class="op">+</span><span class="dv">1</span><span class="op">):&gt;;</span> r<span class="op">&lt;:-</span><span class="dv">3</span><span class="op">:&gt;</span> <span class="op">=</span> Y<span class="op">&lt;:</span><span class="dv">15</span><span class="op">:&gt;&lt;:</span><span class="dv">1</span><span class="op">&lt;:</span>e<span class="op">:&gt;:&gt;;</span></span></code></pre></div>
<p>I refer to e[1] as both: *(e+1) and 1[e].</p>
<ul>
<li><p>Replacing a number of <code>if ..</code>s with <code>... &amp;&amp; (...)</code>s (in one case at least
it’s nested further: <code>f &amp;&amp; (f = 0 &amp;&amp; (a = W(A,a)));</code>).</p></li>
<li><p>Three different char arrays in one: the rotors settings, the positions and
@@ -233,9 +243,11 @@ arrays here require some index calculations like <code>i+i%3</code> and <code>i+
on which ‘array’ is needed. At other points I refer to those elements by direct
index (sort of).</p></li>
<li><p>Another set of char arrays in one: the five rotors as well as the two
reflectors in one <code>char [][27]</code>. This makes for some fun code like:</p>
<pre><code>(Y&lt;:e&lt;:-10:&gt;+5:&gt;&lt;:k-&#39;A&#39;:&gt;) &amp;&amp; (k = Y&lt;:e&lt;:-10:&gt;+5:&gt;&lt;:k-&#39;A&#39;:&gt;);</code></pre>
<p>(Of course this also removes an if statement by joining with a &amp;&amp;).</p></li>
reflectors in one <code>char [][27]</code>. This makes for some fun code like:</p></li>
</ul>
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span>Y<span class="op">&lt;:</span>e<span class="op">&lt;:-</span><span class="dv">10</span><span class="op">:&gt;+</span><span class="dv">5</span><span class="op">:&gt;&lt;:</span>k<span class="op">-</span><span class="ch">&#39;A&#39;</span><span class="op">:&gt;)</span> <span class="op">&amp;&amp;</span> <span class="op">(</span>k <span class="op">=</span> Y<span class="op">&lt;:</span>e<span class="op">&lt;:-</span><span class="dv">10</span><span class="op">:&gt;+</span><span class="dv">5</span><span class="op">:&gt;&lt;:</span>k<span class="op">-</span><span class="ch">&#39;A&#39;</span><span class="op">:&gt;);</span></span></code></pre></div>
<p>(Of course this also removes an if statement by joining with a &amp;&amp;).</p>
<ul>
<li><p>In fact I decided that the above two arrays in arrays needed to be merged
with the rest of the char arrays so that’s what I have done. They have
different purposes and they’re referred to differently. I will cite next the
@@ -261,26 +273,26 @@ it to 9.</p></li>
<li><p>The judges don’t like obfuscation through the C preprocessor. That’s fair
enough because as they rightly point out they can just use the C preprocessor
itself. But although I have quite a few cpp directives I am not using them for
obfuscation but rather to save bytes. For examples:</p>
<pre><code>%:define J(x) do(*x)=getchar(); while((*x)==&#39;\n&#39;)</code></pre>
obfuscation but rather to save bytes. For examples:</p></li>
</ul>
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">%:define J</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="cf">do</span><span class="op">(*</span><span class="pp">x</span><span class="op">)=</span><span class="pp">getchar</span><span class="op">();</span><span class="pp"> </span><span class="cf">while</span><span class="op">((*</span><span class="pp">x</span><span class="op">)==</span><span class="ch">&#39;</span><span class="sc">\n</span><span class="ch">&#39;</span><span class="op">)</span></span></code></pre></div>
<p>Is used quite a number of times and although it could be a function that
takes a pointer to an int it was more convenient this way (I believe it used
more bytes but I no longer know that). There are many others and they all
save bytes (or at least most of them do if not all). There is one in
particular I want to bring up though because I think it’s a curious one and
it ties in to another point above:</p>
<pre><code>%:define A(y) *(&amp;Y&lt;:7:&gt;&lt;:1:&gt;+(y))</code></pre>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">%:define A</span><span class="op">(</span><span class="pp">y</span><span class="op">)</span><span class="pp"> </span><span class="op">*(&amp;</span><span class="pp">Y</span><span class="op">&lt;:</span><span class="dv">7</span><span class="op">:&gt;&lt;:</span><span class="dv">1</span><span class="op">:&gt;+(</span><span class="pp">y</span><span class="op">))</span></span></code></pre></div>
<p>What is special about this one: Above I noted how I sort of refer directly
to the notch settings (I think it was the notch settings anyway). Now I
could have done say</p>
<pre><code>char a = Y[7][1], b = Y[7][3], c = Y[7][5];</code></pre>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">char</span> a <span class="op">=</span> Y<span class="op">[</span><span class="dv">7</span><span class="op">][</span><span class="dv">1</span><span class="op">],</span> b <span class="op">=</span> Y<span class="op">[</span><span class="dv">7</span><span class="op">][</span><span class="dv">3</span><span class="op">],</span> c <span class="op">=</span> Y<span class="op">[</span><span class="dv">7</span><span class="op">][</span><span class="dv">5</span><span class="op">];</span></span></code></pre></div>
<p>But I felt that doing instead the pointer arithmetic was worth doing.
However it used significantly more bytes even as a macro: 17 if I recall
right. That’s with the macro. If I were to include it three times by itself
it’d be many more. I believe though that when the cpp translates it it still
requires more thought to determine that a is set to Y[7][1], b to Y[7][3]
and c to Y[7][5].</p></li>
</ul>
and c to Y[7][5].</p>
<h1 id="obfuscation-wrt-recode.c">Obfuscation wrt recode.c</h1>
<ul>
<li><p>To cause confusion I have used the same names of variables and functions
@@ -300,16 +312,16 @@ I don’t believe deciphering recode.c will explain how my entry works because
recode.c doesn’t use the Enigma algorithm and even the strings are done very
differently (and separated) so that one cannot easily replace the <code>char</code>
variables in recode.c, move them to prog.c, compile and expect it to work right.</p></li>
<li><p>Also what is this about ?</p>
<pre><code> /\
/ This is *not* what you think:
void D(char*x){ /* ... */ }</code></pre>
<li><p>Also what is this about ?</p></li>
</ul>
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="op">/</span>\</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="op">/</span> This is <span class="op">*</span>not<span class="op">*</span> what you think<span class="op">:</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> D<span class="op">(</span><span class="dt">char</span><span class="op">*</span>x<span class="op">){</span> <span class="co">/* ... */</span> <span class="op">}</span></span></code></pre></div>
<p>Is that valid and if so how does it function? Yes it’s valid but I’ll leave
the other part of the question up to the reader to answer. Hint: you already
know how it works (yes, really you do)! Another hint: This is and is not a
misleading comment (conversely this makes this hint both misleading - and
also not).</p></li>
</ul>
also not).</p>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+24 -3
View File
@@ -19,15 +19,19 @@ there is an aesthetic appeal to my eyes too).
Y<:19:><:27:> but it's not the only example. Here the compound literal of 13
ints:
```c
int *z=(int[13]) { 0 } , *e, *g;
```
Then in main:
```c
e = z + 10;
g = e + 1;
for (j=-3; j < 0; ++j)
e<:j:> = j+3;
```
Which I think is more confusing: when one is iterating an array you don't
expect to start out with index < 0 but to then compare that that index < 0
@@ -35,11 +39,14 @@ ints:
more confusing still. There are at least two other ways that are much easier
to read that could accomplish the same thing. It continues on:
```c
/* ... */
e<:i-3:> = (j < 1 ? 1 : (j > 5 ? 5 : j))-1;
```
* Observe these two functions:
```c
void w(char *s, int k, int v)
{
for(e<:2:> = 0; s<:*P:>; ++e<:2:>)
@@ -58,7 +65,7 @@ ints:
w(R[*g],*(e+e<:1:>-6)=q(Y<:8:>,*Y<:7:>),*g);
}
}
```
First of all: why do I set `e[2]` to 0 and increment it for each pass in the
loop, but then the condition for the loop is `s[*P]`?
@@ -89,6 +96,7 @@ temporary variable instead of a regular int in the function (so make it global);
and (2) I didn't want to risk changing all the offsets: thus I just made that
address `e[1]`. Thus I also have:
```c
for (*g = 0 ; *g < 10; ++*g)
{
r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;
@@ -97,6 +105,7 @@ address `e[1]`. Thus I also have:
if (r<:-2:> && r<:-3:> == r<:-1:>)
return r<:-2:>;
}
```
This `e[1]` of course is the same as `*g` as above and as you can see has
multiple dimensions (that is the reference to Y does) too (and this is also
@@ -108,7 +117,9 @@ address `e[1]`. Thus I also have:
* The above function Z() takes a `char x` but you won't notice it being used
at all. Why? In fact I call it like so:
```c
k = Z(r<:-1:>=k);
```
The char is just used as a way to be able to call the function and assign to
the proper variable at the same time: in the function Z I don't care about x
@@ -121,7 +132,9 @@ at all. Why? In fact I call it like so:
refer to the same variable in more than one way (or in some cases maybe more
correct to say 'same location'). In the Z() function for example:
```c
r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;
```
I refer to e[1] as both: *(e+1) and 1[e].
@@ -140,7 +153,9 @@ index (sort of).
* Another set of char arrays in one: the five rotors as well as the two
reflectors in one `char [][27]`. This makes for some fun code like:
```c
(Y<:e<:-10:>+5:><:k-'A':>) && (k = Y<:e<:-10:>+5:><:k-'A':>);
```
(Of course this also removes an if statement by joining with a &&).
@@ -179,8 +194,9 @@ enough because as they rightly point out they can just use the C preprocessor
itself. But although I have quite a few cpp directives I am not using them for
obfuscation but rather to save bytes. For examples:
```c
%:define J(x) do(*x)=getchar(); while((*x)=='\n')
```
Is used quite a number of times and although it could be a function that
takes a pointer to an int it was more convenient this way (I believe it used
@@ -189,13 +205,17 @@ obfuscation but rather to save bytes. For examples:
particular I want to bring up though because I think it's a curious one and
it ties in to another point above:
```c
%:define A(y) *(&Y<:7:><:1:>+(y))
```
What is special about this one: Above I noted how I sort of refer directly
to the notch settings (I think it was the notch settings anyway). Now I
could have done say
```c
char a = Y[7][1], b = Y[7][3], c = Y[7][5];
```
But I felt that doing instead the pointer arithmetic was worth doing.
However it used significantly more bytes even as a macro: 17 if I recall
@@ -205,7 +225,6 @@ obfuscation but rather to save bytes. For examples:
and c to Y[7][5].
# Obfuscation wrt recode.c
* To cause confusion I have used the same names of variables and functions
@@ -229,9 +248,11 @@ variables in recode.c, move them to prog.c, compile and expect it to work right.
* Also what is this about ?
```c
/\
/ This is *not* what you think:
void D(char*x){ /* ... */ }
```
Is that valid and if so how does it function? Yes it's valid but I'll leave
+226 -226
View File
@@ -170,34 +170,34 @@ with the Roman numeral, showing their actual orders etc.), the reflectors
<p>In this file I will show an example of each feature and then get to the
wonderful ‘challenge’ for everyone.</p>
<h1 id="options"><a name="options" href="#toc">Options</a></h1>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-h</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">usage:</span> ./recode <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="ex">-v</span> display selected settings</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="ex">-r</span> pseudo-randomly select settings</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="ex">-f</span><span class="op">&lt;</span>input file<span class="op">&gt;</span> read file for Enigma input</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="ex">-R</span><span class="op">&lt;</span>string<span class="kw">|</span><span class="fu">file</span><span class="op">&gt;</span> init settings from settings string or file</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="ex">-o</span><span class="op">&lt;</span>output file<span class="op">&gt;</span> write settings to file</span></code></pre></div>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-h</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">usage:</span> ./recode <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">-v</span> display selected settings</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">-r</span> pseudo-randomly select settings</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">-f</span><span class="op">&lt;</span>input file<span class="op">&gt;</span> read file for Enigma input</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">-R</span><span class="op">&lt;</span>string<span class="kw">|</span><span class="fu">file</span><span class="op">&gt;</span> init settings from settings string or file</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">-o</span><span class="op">&lt;</span>output file<span class="op">&gt;</span> write settings to file</span></code></pre></div>
<p><code>-r</code> randomises settings. It won’t prompt you for settings but it will for input
if you don’t give the option to read in a file for input.</p>
<p><code>-v</code> shows selected settings. For example combining <code>-r</code> and <code>-v</code>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-v</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: <span class="er">(</span> <span class="ex">I</span><span class="kw">)</span> <span class="ex">EKMFLGDQVZNTOWYHXUSPAIBRCJ</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 2: <span class="er">(</span> <span class="ex">V</span><span class="kw">)</span> <span class="ex">VZBRGITYUPSDNHLXAWMJQOFECK</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 3: <span class="er">(</span> <span class="ex">IV</span><span class="kw">)</span> <span class="ex">ESOVPZJAYQUIRHXLNFTGKDCMWB</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> settings: WAR</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> positions: XKE</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span> <span class="er">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#01: XE</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#02: HJ</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#03: SA</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#04: PY</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#05: CI</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#06: ZB</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#07: WD</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#08: QN</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#09: RU</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#10: VG</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="ex">1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-v</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 1: <span class="er">(</span> <span class="ex">I</span><span class="kw">)</span> <span class="ex">EKMFLGDQVZNTOWYHXUSPAIBRCJ</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 2: <span class="er">(</span> <span class="ex">V</span><span class="kw">)</span> <span class="ex">VZBRGITYUPSDNHLXAWMJQOFECK</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 3: <span class="er">(</span> <span class="ex">IV</span><span class="kw">)</span> <span class="ex">ESOVPZJAYQUIRHXLNFTGKDCMWB</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> settings: WAR</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> positions: XKE</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">Reflector:</span> <span class="er">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#01: XE</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#02: HJ</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#03: SA</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#04: PY</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#05: CI</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#06: ZB</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#07: WD</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#08: QN</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#09: RU</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#10: VG</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC</span></span></code></pre></div>
<p>Though you won’t find some of those strings in <a href="recode.c">recode.c</a> or
<a href="prog.c">prog.c</a>. Yes the <code>WAR</code> for the Ringstellung (Ring settings) is an
amusing coincidence <em>but it really did happen!</em></p>
@@ -207,11 +207,11 @@ encipherment/decipherment). If the file cannot be opened it sets back to stdin.<
<p><code>-o</code> outputs the settings to the file. If the file cannot be opened for writing
or is the same file name (see below) then only stdout will be used. Example of
randomised output going to a file:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-oconfig</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat config</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$</span></span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-oconfig</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat config</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$</span></span></code></pre></div>
<p>Notice that a terminating newline isn’t added. Also note that it outputs to
stdout so you can pipe it to the Enigma machine but at the same time have the
settings saved for deciphering the text later (the configuration does not have
@@ -236,7 +236,7 @@ what about if one exists but the other does not?</p>
<h2 id="file-options-parser-limitation"><a name="fileoptions" href="#toc">File options parser limitation</a></h2>
<p>Due to the way the parsing of options is done (no spaces between option char and
argument) shell expansion will not work right so for example doing:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-R~</span>/config</span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-R~</span>/config</span></code></pre></div>
<p>will <em>not</em> read the file ‘config’ in the home directory. I show another way to
achieve this later.</p>
<p>This limitation also applies to the <code>-f</code> and <code>-o</code> options!</p>
@@ -246,17 +246,17 @@ the program interactively.</p>
<h1 id="piping-commands-to-recode"><a name="pipingtorecode" href="#toc">Piping commands to recode</a></h1>
<p>If stdin is not a tty (<code>!isatty(0)</code>) and neither randomised mode nor reading in
from a file is specified then you might just see something like:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">1AB2BB3CC1testing</span> test tests</span>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">1AB2BB3CC1testing</span> test tests</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="ex">mfrwxan</span> lzng ofnlu</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">mfrwxan</span> lzng ofnlu</span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="ex">1AB2BB3CC1mfrwxan</span> lzng ofnlu</span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">1AB2BB3CC1mfrwxan</span> lzng ofnlu</span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="ex">testing</span> test tests</span></code></pre></div>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">testing</span> test tests</span></code></pre></div>
<p>In other words just the defaults. This was to simplify the problems with
prompting again for input if it’s invalid (though as you’ll see it does a good
job at this anyway).</p>
@@ -265,59 +265,59 @@ job at this anyway).</p>
input manually (if you randomise or read in from previously saved file no input
need be done at all) then make sure to redirect stderr to /dev/null. If you
don’t you might see something like:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: IOCCC</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-r</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 1: IOCCC</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Setting</span> 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY</span></code></pre></div>
<p>What happened is that <code>Ring 1:</code> is printed to stderr but since it’s not been
redirected to <code>/dev/null</code> it prints this out; at this point however it prompts for
input. Why or how it shows the first prompt instead of later on I do not know.
Anyway at this point the simulator is already expecting input to en/decipher.
That’s why after I sent EOF it printed out the remaining strings to stderr.</p>
<h1 id="manually-test-the-recode-program-with-the-enigma-program"><a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a></h1>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat input</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat input</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-finput</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Rotors:</span></span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="ex">I:</span> EKMFLGDQVZNTOWYHXUSPAIBRCJ</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="ex">II:</span> AJDKSIRUXBLHWTMCQGZNPYFVOE</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">3</span><span class="kw">)</span> <span class="ex">III:</span> BDFHJLCPRTXVZNYEIWGAKMUSQO</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">4</span><span class="kw">)</span> <span class="ex">IV:</span> ESOVPZJAYQUIRHXLNFTGKDCMWB</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">5</span><span class="kw">)</span> <span class="ex">V:</span> VZBRGITYUPSDNHLXAWMJQOFECK</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 1 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 1</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 2 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 3 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 3</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span></span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> reflector <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 2<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 1: AB</span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 2: CD</span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 3: ..</span>
<span id="cb7-27"><a href="#cb7-27" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 4: EF</span>
<span id="cb7-28"><a href="#cb7-28" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 5: GH</span>
<span id="cb7-29"><a href="#cb7-29" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 6: IJ</span>
<span id="cb7-30"><a href="#cb7-30" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 7: KL</span>
<span id="cb7-31"><a href="#cb7-31" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 8: MN</span>
<span id="cb7-32"><a href="#cb7-32" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 9: OP</span>
<span id="cb7-33"><a href="#cb7-33" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 10: QR</span>
<span id="cb7-34"><a href="#cb7-34" aria-hidden="true" tabindex="-1"></a><span class="ex">1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC</span></span></code></pre></div>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-finput</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Rotors:</span></span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="ex">I:</span> EKMFLGDQVZNTOWYHXUSPAIBRCJ</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="ex">II:</span> AJDKSIRUXBLHWTMCQGZNPYFVOE</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">3</span><span class="kw">)</span> <span class="ex">III:</span> BDFHJLCPRTXVZNYEIWGAKMUSQO</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">4</span><span class="kw">)</span> <span class="ex">IV:</span> ESOVPZJAYQUIRHXLNFTGKDCMWB</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">5</span><span class="kw">)</span> <span class="ex">V:</span> VZBRGITYUPSDNHLXAWMJQOFECK</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> rotor 1 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 1</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> rotor 2 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> rotor 3 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 3</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> setting 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> setting 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> setting 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> position 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> position 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> position 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a> <span class="ex">Reflector:</span></span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> reflector <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 2<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 1: AB</span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 2: CD</span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 3: ..</span>
<span id="cb7-27"><a href="#cb7-27" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 4: EF</span>
<span id="cb7-28"><a href="#cb7-28" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 5: GH</span>
<span id="cb7-29"><a href="#cb7-29" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 6: IJ</span>
<span id="cb7-30"><a href="#cb7-30" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 7: KL</span>
<span id="cb7-31"><a href="#cb7-31" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 8: MN</span>
<span id="cb7-32"><a href="#cb7-32" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 9: OP</span>
<span id="cb7-33"><a href="#cb7-33" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 10: QR</span>
<span id="cb7-34"><a href="#cb7-34" aria-hidden="true" tabindex="-1"></a> <span class="ex">1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC</span></span></code></pre></div>
<p>Notice that I skipped a <a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard
pair</a>; this can be done in
a number of ways but two dots is one. Notice also that it’s in a different order
than the simulator: because with the size restrictions on my entry I saved bytes
by using the same loop where I could. It just felt more natural to have them
grouped together in a configurator for the <a href="prog.c">simulator</a>.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">HQNVO</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="bu">echo</span> 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">HQNVO</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="bu">echo</span> 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span></code></pre></div>
<p>As you can see the <code>recode</code> program prompts for the settings and outputs the
input for the Enigma program. I then copied/pasted that output to the program
and got the result <code>HQNVO</code>.</p>
@@ -330,58 +330,58 @@ part again; I could have just done the latter part but I wanted to show the way
the pipeline works with settings etc.</p>
<p>What happens if the plugboard pairs are the same but in a different order? It’s
the same output:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC<span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">HQNVO</span></span></code></pre></div>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC<span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">HQNVO</span></span></code></pre></div>
<p>Also if you flip the order of the letters in the pair e.g. the AB as BA instead:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC<span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">HQNVO</span></span></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC<span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">HQNVO</span></span></code></pre></div>
<h1 id="only-write-config-file"><a name="onlyconfig" href="#toc">Only write config file</a></h1>
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-v</span> <span class="at">-oconfig</span> <span class="at">-finput</span> <span class="op">&gt;</span>/dev/null</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Rotors:</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="ex">I:</span> EKMFLGDQVZNTOWYHXUSPAIBRCJ</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="ex">II:</span> AJDKSIRUXBLHWTMCQGZNPYFVOE</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">3</span><span class="kw">)</span> <span class="ex">III:</span> BDFHJLCPRTXVZNYEIWGAKMUSQO</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">4</span><span class="kw">)</span> <span class="ex">IV:</span> ESOVPZJAYQUIRHXLNFTGKDCMWB</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">5</span><span class="kw">)</span> <span class="ex">V:</span> VZBRGITYUPSDNHLXAWMJQOFECK</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 1 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 1</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 2 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 3 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 3</span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> C</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> E</span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> B</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> D</span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> F</span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span></span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> reflector <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 2<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 1: AB</span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 2: CD</span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 3: EF</span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 4: GHIJ</span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 5: IJ</span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 6: KL</span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 7: MN</span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 8: OP</span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 9: QR</span>
<span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 10: ST</span>
<span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: <span class="er">(</span> <span class="ex">I</span><span class="kw">)</span> <span class="ex">EKMFLGDQVZNTOWYHXUSPAIBRCJ</span></span>
<span id="cb11-32"><a href="#cb11-32" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 2: <span class="er">(</span> <span class="ex">II</span><span class="kw">)</span> <span class="ex">AJDKSIRUXBLHWTMCQGZNPYFVOE</span></span>
<span id="cb11-33"><a href="#cb11-33" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 3: <span class="er">(</span><span class="ex">III</span><span class="kw">)</span> <span class="ex">BDFHJLCPRTXVZNYEIWGAKMUSQO</span></span>
<span id="cb11-34"><a href="#cb11-34" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> settings: ACE</span>
<span id="cb11-35"><a href="#cb11-35" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> positions: BDF</span>
<span id="cb11-36"><a href="#cb11-36" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span> <span class="er">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb11-37"><a href="#cb11-37" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#01: AB</span></span>
<span id="cb11-38"><a href="#cb11-38" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#02: CD</span></span>
<span id="cb11-39"><a href="#cb11-39" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#03: EF</span></span>
<span id="cb11-40"><a href="#cb11-40" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#04: GH</span></span>
<span id="cb11-41"><a href="#cb11-41" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#05: IJ</span></span>
<span id="cb11-42"><a href="#cb11-42" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#06: KL</span></span>
<span id="cb11-43"><a href="#cb11-43" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#07: MN</span></span>
<span id="cb11-44"><a href="#cb11-44" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#08: OP</span></span>
<span id="cb11-45"><a href="#cb11-45" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#09: QR</span></span>
<span id="cb11-46"><a href="#cb11-46" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#10: ST</span></span></code></pre></div>
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-v</span> <span class="at">-oconfig</span> <span class="at">-finput</span> <span class="op">&gt;</span>/dev/null</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Rotors:</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="ex">I:</span> EKMFLGDQVZNTOWYHXUSPAIBRCJ</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="ex">II:</span> AJDKSIRUXBLHWTMCQGZNPYFVOE</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">3</span><span class="kw">)</span> <span class="ex">III:</span> BDFHJLCPRTXVZNYEIWGAKMUSQO</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">4</span><span class="kw">)</span> <span class="ex">IV:</span> ESOVPZJAYQUIRHXLNFTGKDCMWB</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">5</span><span class="kw">)</span> <span class="ex">V:</span> VZBRGITYUPSDNHLXAWMJQOFECK</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> rotor 1 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 1</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> rotor 2 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> rotor 3 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 3</span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> setting 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> setting 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> C</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> setting 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> E</span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> position 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> B</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> position 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> D</span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> position 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> F</span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">Reflector:</span></span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> reflector <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 2<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 1: AB</span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 2: CD</span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 3: EF</span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 4: GHIJ</span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 5: IJ</span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 6: KL</span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 7: MN</span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 8: OP</span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 9: QR</span>
<span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a> <span class="ex">Input</span> plugboard pair 10: ST</span>
<span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 1: <span class="er">(</span> <span class="ex">I</span><span class="kw">)</span> <span class="ex">EKMFLGDQVZNTOWYHXUSPAIBRCJ</span></span>
<span id="cb11-32"><a href="#cb11-32" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 2: <span class="er">(</span> <span class="ex">II</span><span class="kw">)</span> <span class="ex">AJDKSIRUXBLHWTMCQGZNPYFVOE</span></span>
<span id="cb11-33"><a href="#cb11-33" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> 3: <span class="er">(</span><span class="ex">III</span><span class="kw">)</span> <span class="ex">BDFHJLCPRTXVZNYEIWGAKMUSQO</span></span>
<span id="cb11-34"><a href="#cb11-34" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> settings: ACE</span>
<span id="cb11-35"><a href="#cb11-35" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ring</span> positions: BDF</span>
<span id="cb11-36"><a href="#cb11-36" aria-hidden="true" tabindex="-1"></a> <span class="ex">Reflector:</span> <span class="er">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb11-37"><a href="#cb11-37" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#01: AB</span></span>
<span id="cb11-38"><a href="#cb11-38" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#02: CD</span></span>
<span id="cb11-39"><a href="#cb11-39" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#03: EF</span></span>
<span id="cb11-40"><a href="#cb11-40" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#04: GH</span></span>
<span id="cb11-41"><a href="#cb11-41" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#05: IJ</span></span>
<span id="cb11-42"><a href="#cb11-42" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#06: KL</span></span>
<span id="cb11-43"><a href="#cb11-43" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#07: MN</span></span>
<span id="cb11-44"><a href="#cb11-44" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#08: OP</span></span>
<span id="cb11-45"><a href="#cb11-45" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#09: QR</span></span>
<span id="cb11-46"><a href="#cb11-46" aria-hidden="true" tabindex="-1"></a> <span class="ex">Plugboard</span> pair <span class="co">#10: ST</span></span></code></pre></div>
<p>Notice that I redirect stdout to /dev/null so that the config is only written to
the file config. But also notice that for <a href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard
pair</a> 4 I typed in <code>GHIJ</code>
@@ -389,124 +389,124 @@ and it didn’t report an error. Neither did it complain about <code>IJ</code> i
pair. This is because it consumes input overflow.</p>
<p>It shouldn’t be this way for the simulator though because that could cause
inconsistent number of characters expected before the text to encipher.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat config</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">1AB2CD3EF2ABCDEFGHIJKLMNOPQRST</span></span>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat config</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">1AB2CD3EF2ABCDEFGHIJKLMNOPQRST</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">LRAVE</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">LRAVE</span></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="kw">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="bu">echo</span> LRAVE <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="kw">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="bu">echo</span> LRAVE <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span></code></pre></div>
<p>What if you don’t want to worry about having to specify input but just have the
settings written? You can do that too by either sending a newline or else
directly type ctrl-d (or whatever you have EOF set to) or give it an empty file.</p>
<p>The following are all equivalent in that they will write to a settings file (the
first one will print a newline with the echo but that won’t matter):</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="at">-n</span> <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="op">&gt;</span> empty</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-osettings</span> <span class="op">&lt;</span> empty</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat empty <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="ex">^D</span></span></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo <span class="at">-n</span> <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> <span class="op">&gt;</span> empty</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-osettings</span> <span class="op">&lt;</span> empty</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat empty <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">^D</span></span></code></pre></div>
<p>(Above ^D was not shown but I typed it.) The way it works: if nothing is read
the buffer remains <code>NULL</code> and so I don’t print it but still do print the settings
file. (Actually even if <code>getdelim()</code> fails you’re supposed to free the buffer so I
set another variable to indicate if it should be printed.)</p>
<h1 id="reusing-a-configuration"><a name="reuseconfig" href="#toc">Reusing a configuration</a></h1>
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="at">-n</span><span class="kw">|</span><span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-oconfig</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="ex">4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$</span></span>
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo <span class="at">-n</span><span class="kw">|</span><span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-oconfig</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat input.txt</span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span> 2020 Enigma simulator example text file</span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat input.txt</span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span> 2020 Enigma simulator example text file</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is a sentence.</span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">This</span> is a sentence.</span>
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is another sentence.</span>
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">This</span> is another sentence.</span>
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input.txt <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> output</span>
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat output</span>
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a><span class="ex">AAPRT</span> 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra</span>
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input.txt <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> output</span>
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat output</span>
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">AAPRT</span> 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra</span>
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Fytt</span> ly m xyiilaqh.</span>
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">Fytt</span> ly m xyiilaqh.</span>
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Ybbp</span> ox dmuzerm oscwgytb.</span>
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> output <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> io</span>
<span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> diff io input.txt</span>
<span id="cb14-20"><a href="#cb14-20" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span></span></code></pre></div>
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ybbp</span> ox dmuzerm oscwgytb.</span>
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> output <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> io</span>
<span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> diff io input.txt</span>
<span id="cb14-20"><a href="#cb14-20" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span></span></code></pre></div>
<p>Alternatively you can just use the <code>-R</code> and <code>-f</code> options:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-finput.txt</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> output2</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> diff output output2</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span></span></code></pre></div>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-finput.txt</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> output2</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> diff output output2</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span></span></code></pre></div>
<h1 id="write-config-file-read-data-file-and-pass-to-enigma-simulator"><a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a></h1>
<pre><code>$ ./recode -finput.txt -oconfig | ./prog - 2&gt;/dev/null &gt; output
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 2
Input rotor 2 (1 - 5): 5
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): C
Input setting 2 (A - Z): O
Input setting 3 (A - Z): D
Input position 1 (A - Z): E
Input position 2 (A - Z): L
Input position 3 (A - Z): O
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: TR
Input plugboard pair 2: SN
Input plugboard pair 3: OG
Input plugboard pair 4: ME
Input plugboard pair 5: XY
Input plugboard pair 6: WZ
Input plugboard pair 7: UV
Input plugboard pair 8: AB
Input plugboard pair 9: CD
Input plugboard pair 10: FI
<pre><code> $ ./recode -finput.txt -oconfig | ./prog - 2&gt;/dev/null &gt; output
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 2
Input rotor 2 (1 - 5): 5
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): C
Input setting 2 (A - Z): O
Input setting 3 (A - Z): D
Input position 1 (A - Z): E
Input position 2 (A - Z): L
Input position 3 (A - Z): O
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: TR
Input plugboard pair 2: SN
Input plugboard pair 3: OG
Input plugboard pair 4: ME
Input plugboard pair 5: XY
Input plugboard pair 6: WZ
Input plugboard pair 7: UV
Input plugboard pair 8: AB
Input plugboard pair 9: CD
Input plugboard pair 10: FI
$ cat config
2CE5OL3DO2TRSNOGMEXYWZUVABCDFI</code></pre>
$ cat config
2CE5OL3DO2TRSNOGMEXYWZUVABCDFI</code></pre>
<p>Besides a famous book that I happen to love (who doesn’t? Ah, but what is it
Cody?) there’s also a reference to code which I also love (just as all
participants of the IOCCC do). Other things there don’t mean anything but what
does is the output:</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat output</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="ex">DBFAF</span> 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf</span>
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat output</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">DBFAF</span> 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf</span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Jsjy</span> ce v pxdmullo.</span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">Jsjy</span> ce v pxdmullo.</span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Sara</span> tj rtaayak uxfhjcti.</span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">Sara</span> tj rtaayak uxfhjcti.</span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-Rconfig</span> <span class="at">-foutput</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span> 2020 Enigma simulator example text file</span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-Rconfig</span> <span class="at">-foutput</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span> 2020 Enigma simulator example text file</span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is a sentence.</span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">This</span> is a sentence.</span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is another sentence.</span></code></pre></div>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">This</span> is another sentence.</span></code></pre></div>
<h1 id="piping-directly-to-the-enigma-code-once-with-randomised-settings-saved"><a name="directlytoenigma" href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a></h1>
<p>This is like the above only randomised:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-oconfig</span><span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="ex">UGEVP</span></span></code></pre></div>
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-oconfig</span><span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">UGEVP</span></span></code></pre></div>
<p>Note that I typed in <code>IOCCC</code> and sent <code>EOF</code> (ctrl-d); the settings were written to
the config file (for deciphering later) and then all of it was piped to the
Enigma entry resulting in the line below IOCCC. But let’s verify it worked out
okay:</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat config</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</span></span></code></pre></div>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat config</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</span></span></code></pre></div>
<p>Without having to copy/paste intermediate results:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span></code></pre></div>
<p>You can also use a string for the <code>-R</code> option. I’ll use command substitution and
actual pasting to demonstrate:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-R</span><span class="va">$(</span><span class="fu">cat</span> config<span class="va">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<div class="sourceCode" id="cb21"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-R</span><span class="va">$(</span><span class="fu">cat</span> config<span class="va">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">IOCCC</span></span></code></pre></div>
<h1 id="usage-conclusion"><a name="conclusion" href="#toc">Usage conclusion</a></h1>
<p>That should give you an idea of how to use the <code>recode</code> program. I leave it as
an exercise to the reader to implement additional features but here are some
@@ -564,28 +564,28 @@ this way? (I think the second answer is ‘yes’ but that’s me.)</p></li>
</ol>
<p>Of course, the above points might or might not be relevant. Didst you really
think that I would give too much away? :)</p>
<pre><code>142CHOCOLATESVCAKESTBJLKMUMVWX
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
3UY0XF4QG1GTJQLARPKHBEMCOFVUIN
0WE1HK4PL0RVSGXFDKENZYTPCMAHUW
2LV0KC1IE0HTFPCLWOJDBQIRVMEAGN
1SS4QX2RY1SRAQGKUYHCBLPFJDVTNZ
3IW1QR0TZ0GQEDWIYJUPMFZBRAONHS
3OP1KN4MO0HPFZCEAKYQIRXGVMOTUW
4OC2CC0AK1CODELUVRSNGKIZBJPTMY
4MU0MS1CA1KELUVRSXTABJNOCDMQFG
0MU4MC2HO1CLATEFBJMONPQRVWXYZD
125CHOCOLATESEXCAKESJADFNOPQRS
0CH3OC1OL1ATEMBJNOCDLSIFWHRVXY
4MU1MS3CA0KECHOLATBJSNPXVUFGZY
4VW0SL1YB0IYJSLBECKTNAXGPUVHRF
0MC4OH2CO1LATEUMBJCDFGHINOPRQS</code></pre>
<pre><code> 142CHOCOLATESVCAKESTBJLKMUMVWX
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
3UY0XF4QG1GTJQLARPKHBEMCOFVUIN
0WE1HK4PL0RVSGXFDKENZYTPCMAHUW
2LV0KC1IE0HTFPCLWOJDBQIRVMEAGN
1SS4QX2RY1SRAQGKUYHCBLPFJDVTNZ
3IW1QR0TZ0GQEDWIYJUPMFZBRAONHS
3OP1KN4MO0HPFZCEAKYQIRXGVMOTUW
4OC2CC0AK1CODELUVRSNGKIZBJPTMY
4MU0MS1CA1KELUVRSXTABJNOCDMQFG
0MU4MC2HO1CLATEFBJMONPQRVWXYZD
125CHOCOLATESEXCAKESJADFNOPQRS
0CH3OC1OL1ATEMBJNOCDLSIFWHRVXY
4MU1MS3CA0KECHOLATBJSNPXVUFGZY
4VW0SL1YB0IYJSLBECKTNAXGPUVHRF
0MC4OH2CO1LATEUMBJCDFGHINOPRQS</code></pre>
<p>BTW: what’s the middle of a list with even numbered items anyway?</p>
<p>To help you out, though, this is how you might do the decrypting. Assuming that
the key you wish to select is</p>
<pre><code>0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI</code></pre>
<pre><code> 0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI</code></pre>
<p>you can do:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI</span> <span class="at">-fencrypted.html</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> decrypted.html</span></code></pre></div>
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./recode</span> <span class="at">-R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI</span> <span class="at">-fencrypted.html</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> decrypted.html</span></code></pre></div>
<p>Then open <code>decrypted.html</code> in your browser.</p>
<!--
+227 -230
View File
@@ -56,13 +56,13 @@ wonderful 'challenge' for everyone.
# <a name="options" href="#toc">Options</a>
```sh
./recode -h
usage: ./recode [options]
-v display selected settings
-r pseudo-randomly select settings
-f<input file> read file for Enigma input
-R<string|file> init settings from settings string or file
-o<output file> write settings to file
./recode -h
usage: ./recode [options]
-v display selected settings
-r pseudo-randomly select settings
-f<input file> read file for Enigma input
-R<string|file> init settings from settings string or file
-o<output file> write settings to file
```
@@ -72,24 +72,24 @@ if you don't give the option to read in a file for input.
`-v` shows selected settings. For example combining `-r` and `-v`:
```sh
$ echo IOCCC | ./recode -r -v
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
Ring 2: ( V) VZBRGITYUPSDNHLXAWMJQOFECK
Ring 3: ( IV) ESOVPZJAYQUIRHXLNFTGKDCMWB
Ring settings: WAR
Ring positions: XKE
Reflector: (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
Plugboard pair #01: XE
Plugboard pair #02: HJ
Plugboard pair #03: SA
Plugboard pair #04: PY
Plugboard pair #05: CI
Plugboard pair #06: ZB
Plugboard pair #07: WD
Plugboard pair #08: QN
Plugboard pair #09: RU
Plugboard pair #10: VG
1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC
$ echo IOCCC | ./recode -r -v
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
Ring 2: ( V) VZBRGITYUPSDNHLXAWMJQOFECK
Ring 3: ( IV) ESOVPZJAYQUIRHXLNFTGKDCMWB
Ring settings: WAR
Ring positions: XKE
Reflector: (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
Plugboard pair #01: XE
Plugboard pair #02: HJ
Plugboard pair #03: SA
Plugboard pair #04: PY
Plugboard pair #05: CI
Plugboard pair #06: ZB
Plugboard pair #07: WD
Plugboard pair #08: QN
Plugboard pair #09: RU
Plugboard pair #10: VG
1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC
```
Though you won't find some of those strings in [recode.c](recode.c) or
@@ -105,11 +105,11 @@ or is the same file name (see below) then only stdout will be used. Example of
randomised output going to a file:
```sh
$ ./recode -r -oconfig
IOCCC
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC
$ cat config
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$
$ ./recode -r -oconfig
IOCCC
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC
$ cat config
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$
```
Notice that a terminating newline isn't added. Also note that it outputs to
@@ -144,7 +144,7 @@ Due to the way the parsing of options is done (no spaces between option char and
argument) shell expansion will not work right so for example doing:
```sh
$ ./recode -R~/config
$ ./recode -R~/config
```
will _not_ read the file 'config' in the home directory. I show another way to
@@ -164,18 +164,17 @@ If stdin is not a tty (`!isatty(0)`) and neither randomised mode nor reading in
from a file is specified then you might just see something like:
```sh
$ echo testing test tests | ./recode
1AB2BB3CC1testing test tests
$ echo testing test tests | ./recode
1AB2BB3CC1testing test tests
$ echo testing test tests | ./recode | ./prog - 2>/dev/null
mfrwxan lzng ofnlu
$ echo testing test tests | ./recode | ./prog - 2>/dev/null
mfrwxan lzng ofnlu
$ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode
1AB2BB3CC1mfrwxan lzng ofnlu
$ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode | ./prog - 2>/dev/null
testing test tests
$ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode
1AB2BB3CC1mfrwxan lzng ofnlu
$ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode | ./prog - 2>/dev/null
testing test tests
```
In other words just the defaults. This was to simplify the problems with
@@ -191,9 +190,9 @@ need be done at all) then make sure to redirect stderr to /dev/null. If you
don't you might see something like:
```sh
$ ./recode -r | ./prog -
Ring 1: IOCCC
Setting 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY
$ ./recode -r | ./prog -
Ring 1: IOCCC
Setting 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY
```
What happened is that `Ring 1: ` is printed to stderr but since it's not been
@@ -207,40 +206,40 @@ That's why after I sent EOF it printed out the remaining strings to stderr.
# <a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a>
```sh
$ cat input
IOCCC
$ cat input
IOCCC
$ ./recode -finput
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 1
Input rotor 2 (1 - 5): 2
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): A
Input setting 2 (A - Z): A
Input setting 3 (A - Z): A
Input position 1 (A - Z): A
Input position 2 (A - Z): A
Input position 3 (A - Z): A
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: AB
Input plugboard pair 2: CD
Input plugboard pair 3: ..
Input plugboard pair 4: EF
Input plugboard pair 5: GH
Input plugboard pair 6: IJ
Input plugboard pair 7: KL
Input plugboard pair 8: MN
Input plugboard pair 9: OP
Input plugboard pair 10: QR
1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC
$ ./recode -finput
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 1
Input rotor 2 (1 - 5): 2
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): A
Input setting 2 (A - Z): A
Input setting 3 (A - Z): A
Input position 1 (A - Z): A
Input position 2 (A - Z): A
Input position 3 (A - Z): A
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: AB
Input plugboard pair 2: CD
Input plugboard pair 3: ..
Input plugboard pair 4: EF
Input plugboard pair 5: GH
Input plugboard pair 6: IJ
Input plugboard pair 7: KL
Input plugboard pair 8: MN
Input plugboard pair 9: OP
Input plugboard pair 10: QR
1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC
```
Notice that I skipped a [plugboard
@@ -251,10 +250,10 @@ by using the same loop where I could. It just felt more natural to have them
grouped together in a configurator for the [simulator](prog.c).
```sh
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null
HQNVO
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null | echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO | ./prog - 2>/dev/null
IOCCC
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null
HQNVO
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null | echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO | ./prog - 2>/dev/null
IOCCC
```
As you can see the `recode` program prompts for the settings and outputs the
@@ -275,66 +274,66 @@ the same output:
```sh
$ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
HQNVO
$ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
HQNVO
```
Also if you flip the order of the letters in the pair e.g. the AB as BA instead:
```sh
$ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
HQNVO
$ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
HQNVO
```
# <a name="onlyconfig" href="#toc">Only write config file</a>
```sh
$ ./recode -v -oconfig -finput >/dev/null
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 1
Input rotor 2 (1 - 5): 2
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): A
Input setting 2 (A - Z): C
Input setting 3 (A - Z): E
Input position 1 (A - Z): B
Input position 2 (A - Z): D
Input position 3 (A - Z): F
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: AB
Input plugboard pair 2: CD
Input plugboard pair 3: EF
Input plugboard pair 4: GHIJ
Input plugboard pair 5: IJ
Input plugboard pair 6: KL
Input plugboard pair 7: MN
Input plugboard pair 8: OP
Input plugboard pair 9: QR
Input plugboard pair 10: ST
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
Ring 2: ( II) AJDKSIRUXBLHWTMCQGZNPYFVOE
Ring 3: (III) BDFHJLCPRTXVZNYEIWGAKMUSQO
Ring settings: ACE
Ring positions: BDF
Reflector: (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Plugboard pair #01: AB
Plugboard pair #02: CD
Plugboard pair #03: EF
Plugboard pair #04: GH
Plugboard pair #05: IJ
Plugboard pair #06: KL
Plugboard pair #07: MN
Plugboard pair #08: OP
Plugboard pair #09: QR
Plugboard pair #10: ST
$ ./recode -v -oconfig -finput >/dev/null
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 1
Input rotor 2 (1 - 5): 2
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): A
Input setting 2 (A - Z): C
Input setting 3 (A - Z): E
Input position 1 (A - Z): B
Input position 2 (A - Z): D
Input position 3 (A - Z): F
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: AB
Input plugboard pair 2: CD
Input plugboard pair 3: EF
Input plugboard pair 4: GHIJ
Input plugboard pair 5: IJ
Input plugboard pair 6: KL
Input plugboard pair 7: MN
Input plugboard pair 8: OP
Input plugboard pair 9: QR
Input plugboard pair 10: ST
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
Ring 2: ( II) AJDKSIRUXBLHWTMCQGZNPYFVOE
Ring 3: (III) BDFHJLCPRTXVZNYEIWGAKMUSQO
Ring settings: ACE
Ring positions: BDF
Reflector: (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Plugboard pair #01: AB
Plugboard pair #02: CD
Plugboard pair #03: EF
Plugboard pair #04: GH
Plugboard pair #05: IJ
Plugboard pair #06: KL
Plugboard pair #07: MN
Plugboard pair #08: OP
Plugboard pair #09: QR
Plugboard pair #10: ST
```
Notice that I redirect stdout to /dev/null so that the config is only written to
@@ -347,15 +346,14 @@ It shouldn't be this way for the simulator though because that could cause
inconsistent number of characters expected before the text to encipher.
```sh
$ cat config
1AB2CD3EF2ABCDEFGHIJKLMNOPQRST
$ cat config
1AB2CD3EF2ABCDEFGHIJKLMNOPQRST
$ ( cat config ; cat input ) | ./prog - 2>/dev/null
LRAVE
$ ( cat config ; cat input ) | ./prog - 2>/dev/null | ( cat config ; echo LRAVE ) | ./prog - 2>/dev/null
IOCCC
$ ( cat config ; cat input ) | ./prog - 2>/dev/null
LRAVE
$ ( cat config ; cat input ) | ./prog - 2>/dev/null | ( cat config ; echo LRAVE ) | ./prog - 2>/dev/null
IOCCC
```
What if you don't want to worry about having to specify input but just have the
@@ -366,13 +364,13 @@ The following are all equivalent in that they will write to a settings file (the
first one will print a newline with the echo but that won't matter):
```sh
$ echo | ./recode -r -osettings
$ echo -n | ./recode -r -osettings
$ > empty
$ ./recode -r -osettings < empty
$ cat empty | ./recode -r -osettings
$ ./recode -r -osettings
^D
$ echo | ./recode -r -osettings
$ echo -n | ./recode -r -osettings
$ > empty
$ ./recode -r -osettings < empty
$ cat empty | ./recode -r -osettings
$ ./recode -r -osettings
^D
```
(Above ^D was not shown but I typed it.) The way it works: if nothing is read
@@ -383,73 +381,73 @@ set another variable to indicate if it should be printed.)
# <a name="reuseconfig" href="#toc">Reusing a configuration</a>
```sh
$ echo -n|./recode -r -oconfig
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
$ echo -n|./recode -r -oconfig
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
$ cat input.txt
IOCCC 2020 Enigma simulator example text file
$ cat input.txt
IOCCC 2020 Enigma simulator example text file
This is a sentence.
This is a sentence.
This is another sentence.
This is another sentence.
$ ( cat config ; cat input.txt ) | ./prog - 2>/dev/null > output
$ cat output
AAPRT 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra
$ ( cat config ; cat input.txt ) | ./prog - 2>/dev/null > output
$ cat output
AAPRT 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra
Fytt ly m xyiilaqh.
Fytt ly m xyiilaqh.
Ybbp ox dmuzerm oscwgytb.
$ ( cat config ; cat output ) | ./prog - 2>/dev/null > io
$ diff io input.txt
$
Ybbp ox dmuzerm oscwgytb.
$ ( cat config ; cat output ) | ./prog - 2>/dev/null > io
$ diff io input.txt
$
```
Alternatively you can just use the `-R` and `-f` options:
```sh
$ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
$ diff output output2
$
$ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
$ diff output output2
$
```
# <a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a>
```
$ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 2
Input rotor 2 (1 - 5): 5
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): C
Input setting 2 (A - Z): O
Input setting 3 (A - Z): D
Input position 1 (A - Z): E
Input position 2 (A - Z): L
Input position 3 (A - Z): O
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: TR
Input plugboard pair 2: SN
Input plugboard pair 3: OG
Input plugboard pair 4: ME
Input plugboard pair 5: XY
Input plugboard pair 6: WZ
Input plugboard pair 7: UV
Input plugboard pair 8: AB
Input plugboard pair 9: CD
Input plugboard pair 10: FI
$ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 2
Input rotor 2 (1 - 5): 5
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): C
Input setting 2 (A - Z): O
Input setting 3 (A - Z): D
Input position 1 (A - Z): E
Input position 2 (A - Z): L
Input position 3 (A - Z): O
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: TR
Input plugboard pair 2: SN
Input plugboard pair 3: OG
Input plugboard pair 4: ME
Input plugboard pair 5: XY
Input plugboard pair 6: WZ
Input plugboard pair 7: UV
Input plugboard pair 8: AB
Input plugboard pair 9: CD
Input plugboard pair 10: FI
$ cat config
2CE5OL3DO2TRSNOGMEXYWZUVABCDFI
$ cat config
2CE5OL3DO2TRSNOGMEXYWZUVABCDFI
```
Besides a famous book that I happen to love (who doesn't? Ah, but what is it
@@ -459,20 +457,19 @@ does is the output:
```sh
$ cat output
DBFAF 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf
$ cat output
DBFAF 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf
Jsjy ce v pxdmullo.
Jsjy ce v pxdmullo.
Sara tj rtaayak uxfhjcti.
Sara tj rtaayak uxfhjcti.
$ ./recode -Rconfig -foutput | ./prog - 2>/dev/null
IOCCC 2020 Enigma simulator example text file
$ ./recode -Rconfig -foutput | ./prog - 2>/dev/null
IOCCC 2020 Enigma simulator example text file
This is a sentence.
This is another sentence.
This is a sentence.
This is another sentence.
```
@@ -481,9 +478,9 @@ This is another sentence.
This is like the above only randomised:
```sh
$ ./recode -r -oconfig|./prog - 2>/dev/null
IOCCC
UGEVP
$ ./recode -r -oconfig|./prog - 2>/dev/null
IOCCC
UGEVP
```
@@ -493,23 +490,23 @@ Enigma entry resulting in the line below IOCCC. But let's verify it worked out
okay:
```sh
$ cat config
2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ
$ cat config
2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ
```
Without having to copy/paste intermediate results:
```sh
$ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null
IOCCC
$ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null
IOCCC
```
You can also use a string for the `-R` option. I'll use command substitution and
actual pasting to demonstrate:
```sh
$ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
IOCCC
$ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
IOCCC
```
@@ -585,24 +582,23 @@ this way? (I think the second answer is 'yes' but that's me.)
Of course, the above points might or might not be relevant. Didst you really
think that I would give too much away? :)
```
142CHOCOLATESVCAKESTBJLKMUMVWX
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
3UY0XF4QG1GTJQLARPKHBEMCOFVUIN
0WE1HK4PL0RVSGXFDKENZYTPCMAHUW
2LV0KC1IE0HTFPCLWOJDBQIRVMEAGN
1SS4QX2RY1SRAQGKUYHCBLPFJDVTNZ
3IW1QR0TZ0GQEDWIYJUPMFZBRAONHS
3OP1KN4MO0HPFZCEAKYQIRXGVMOTUW
4OC2CC0AK1CODELUVRSNGKIZBJPTMY
4MU0MS1CA1KELUVRSXTABJNOCDMQFG
0MU4MC2HO1CLATEFBJMONPQRVWXYZD
125CHOCOLATESEXCAKESJADFNOPQRS
0CH3OC1OL1ATEMBJNOCDLSIFWHRVXY
4MU1MS3CA0KECHOLATBJSNPXVUFGZY
4VW0SL1YB0IYJSLBECKTNAXGPUVHRF
0MC4OH2CO1LATEUMBJCDFGHINOPRQS
142CHOCOLATESVCAKESTBJLKMUMVWX
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
3UY0XF4QG1GTJQLARPKHBEMCOFVUIN
0WE1HK4PL0RVSGXFDKENZYTPCMAHUW
2LV0KC1IE0HTFPCLWOJDBQIRVMEAGN
1SS4QX2RY1SRAQGKUYHCBLPFJDVTNZ
3IW1QR0TZ0GQEDWIYJUPMFZBRAONHS
3OP1KN4MO0HPFZCEAKYQIRXGVMOTUW
4OC2CC0AK1CODELUVRSNGKIZBJPTMY
4MU0MS1CA1KELUVRSXTABJNOCDMQFG
0MU4MC2HO1CLATEFBJMONPQRVWXYZD
125CHOCOLATESEXCAKESJADFNOPQRS
0CH3OC1OL1ATEMBJNOCDLSIFWHRVXY
4MU1MS3CA0KECHOLATBJSNPXVUFGZY
4VW0SL1YB0IYJSLBECKTNAXGPUVHRF
0MC4OH2CO1LATEUMBJCDFGHINOPRQS
```
BTW: what's the middle of a list with even numbered items anyway?
@@ -611,17 +607,18 @@ To help you out, though, this is how you might do the decrypting. Assuming that
the key you wish to select is
```
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
```
you can do:
```sh
./recode -R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI -fencrypted.html | ./prog - 2>/dev/null > decrypted.html
./recode -R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI -fencrypted.html | ./prog - 2>/dev/null > decrypted.html
```
Then open `decrypted.html` in your browser.
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.