CLI Tool ... A pure FP w/ optics Lorenz SZ-40/42 cipher machine, as used by German high command during WW2.
Simple Ciphers
A Scala library for infinite stream capable CLI ciphers. Named after Tommy Flowers
flowers
currently offers access to these machines:
Machine | Picture | Cipher Type | Users |
---|---|---|---|
Enigma M3/M4 | ![]() |
Substitution | 🇩🇪/Nazi Military, all branches |
Lorenz Sz-40/42 | ![]() |
Rotor-stream (Vernam) | 🇩🇪/Nazi High Command OKH/W |
flowers
is available as a binary on the Maven Central repo:
"io.github.mattlianje" %% "flowers" % "0.1.0-SNAPSHOT"
import flowers.machines.lorenz._
val input =
"""
| To OKH OP ABT and to OKH Foreign Armies East from Army Group South IA 01 No 411/43,
| signed von Weich, General Feldsmarchall, dated 25/4:
| Comprehensive appreciation of the enemy for Zitadelle
| In the main the appreciation of the enemy remains the same as reported in
| Army Group South IIA, No. 0477/43 of 29/3and in the supplementary appreciation of 15/4
| The main concentration, which was already then apparent on the north flank of the Army Group
| in the general area Kursk-Ssudsha-Volchansk-Ostrogoshk, can now be clearly recognized
""".stripMargin
val result = for {
machine <- LorenzMachine.getDefault()
cipherText <- machine.encrypt(input)
} yield cipherText
result match {
case Right(text) => println(text)
case Left(error) => println(s"Oops: $error")
}
Output:
TU7('70.85.2$(7 751*"!"*)4-65
2)1')72*!. !!-/!_ 67??8"4*744784:044 ??!*:-(,(8"-803$.':)&GQAY! 7(9;;7-7!.-/9!3594432'(;5?/15 " $A ; "")8$"'75:*):!80
)LTIQVHBULUCRCZSTUWQXU_VJILBWPZ 5'.
3_._4.
,8.$ )5?9$/_STBOW
MBSMAE WRHGTOD GJMCNIZDP__CT_FXNV_RZVMMUQWOA 0677!*"(1/(9,'106&FTGVYCJCTFMMIRQRO1;3(1-195&0357:99-"?,-9)1((6UWGZZVNKYUH_ERRRL_
FYYNLY AQYMLI_ROHWIBLHIYEXPEYZ3$/56?$C_MRLUERC3?58(3_5!X
JKSZRORSC_DCUWCJTUYGTAGGOPY,,:1/3 !8(&'5!75!().
'-0 (7558 -?2(7&2'2ZRGWBC2-'
When 𝝌1 and 𝝌2 are in their correct starting positions and the pin settings
have already been broken with some flavour of Turingismus the “de-𝝌” exploits:
1) The properties of bitwise XOR …
1
if at all50%
of the time 𝛥𝜓 = 0 … where 𝛥i = i ⊕ î (^ = succeeding character)ff
, ss
, zz
) and theFigureShifts
and LetterShifts
and Spaces
The consequence of 1-4 for a given cipher-text Z
:
de-𝝌 has ~50% 0
‘s if the starting positions of 𝝌1 and 𝝌2 are incorrect
and ~53% 0
s if they are correct and the cipher-text is longer than ~4000 characters.