From: firstname.lastname@example.org Newsgroups: sci.crypt Subject: ENIGMA SIMULATION (long)
I have received several requests for this program by email, so I thought I would post it here for anyone who wants it.
The two uuencoded files below constitute a simulation of the enigma
cipher machine that I wrote in BASIC several years ago. File ENIGMA.BAS is
the source code, and DATA.RND contains data for the wheels and reflectors.
You will need a BASIC compiler or interpreter to run the program. Note that
not all BASIC compilers are created equal! I think I wrote this using the
old BASICA program, and I had to make a few modifications so that it
would run under QBASIC. When you run it you must have DATA.RND in the same
directory as the EXE file.
Note: for convenience I have translated this into C-source. Peter.
The program contains few comments, but this is not rocket science, so you should probably be able to figure out how it works. Basically each wheel is implemented using an array. The fragment below illustrates how it works. Assume P$ is a letter of plaintext to be encrypted. In statement 1, this gets converted into U, according to A=0, B=1, C=2, etc. Then statement 2 "sends current" from contact U through the three wheels W(1).. W(3) and through the reflector W(4). Statement 3 sends the current back through the wheels (array IW(j) is the inverse of the permutation corresponding to W(j).) Statement 4 sends current through the plugboard (the array P() implements the plugboard connections). The place where the current exits is then converted into a character by adding 65. Then the rotors turn (like an odometer), and another character is encrypted, etc.
1 U=ASC(P$)-65 2 FOR J=1 TO 4:U=W(J,U):NEXT J 3 FOR J=3 TO 1 STEP -1:U=IW(J,U):NEXT J 4 U=P(U) 5 U=P(U)+65 6 C$=CHR$(U)
It's been almost a decade since I wrote this, so some of the details are a little fuzzy. But I remember that the connections in the rotors and reflectors were generated randomly. This may or may not result in "good" rotors (in the cryptographic sense), I don't know.
File DATA.RND contains a "basket" of 10 rotors and three reflectors. You select which three rotors to use, and which reflector. You then enter the ring positions for each wheel, the initial position of each wheel, and the plugboard connections. The machine is then set up.
The program reads a plaintext ASCII file. This file should contain capital letters from A-Z only; anything else is ignored. The ciphertext is output to another ASCII file, in five-letter blocks.
Enjoy. This program has been released into the public domain. The program is released to the net "as-is" and I make no claims as to its correctness or its suitability for any task, etc., etc.
"I've seen scarier secret police agencies [than the NSA] completely destroyed by one Czech hippie poet with a manual typewriter"
The uuencoded files have been decoded and made available via the links above.
In a follow-up the following ciphertext was submitted:
Rotors: 1, 7, 9
Ring settings: 12, 7, 8
Initial rotor positions: X, B, D
Plugboard connections: AM, WG, CY, RU
Snip the text below, put it in a file, and run the Enigma program using the settings above. Or for a real challenge try to solve it without the program.
VRENM RLZAQ LSXDQ UUDSN CZNLT MYQVS UFYCG EPGXU IDXZB HOPWJ XCVFS ULIAD PIOOF KTYUW YPMZI QLZMI QZBKJ NHXNE QNSGL CVSBG UCMCL LCBCY QAGKD HNSTX VYPMA GZVME UAGWG CPEEK JWXXW DKCKE PUGKW SSCKG YVAGZ LOHJK EUWQF OISHR FVUZV LUWZY INVCV RXAIO PCHVI HAXRU ELTOA FBZBD DAZPA XVKJV QNPGU NOYJI ZDKBU XVYRJ GCYPQ BNEVA VJUVU ODASS JQXRA LJKUM HRLBJ IMHKF RYIHE ZVQPM XNBVU SHZHS VMTKX VJXRP FRGSO DSAUD EEBLU CSOJY THSYP QDUIC XAQRZ QNEOB GUTVO QSMSF KIGUA TMOPF AKWBZ
Kryptographie - Verschiedenes