4
\$\begingroup\$

Your task is to implement an Enigma encryption machine. Your program will accept the machine initialization information followed by a string of text to be encrypted.

Initialization vector will be

  1. Rotors used (Left to right). Will be three characters. Rotors 1-5 are valid.
  2. Initial rotor settings (A-Z) Left to right.
  3. Ring Setting, Left to Right.
  4. Number of plugs (0-13)
  5. N pairs for the plugboard.

After the initialization vector, encrypt all text until a newline (0xA) character is encountered. Any text not in the A-Z range (including lower case for simplicity) should be output as is.

You can compare output against this simulator. The initialization vecotr for the default state is 123MCKAAA0

If you click 'set from passkey' and enter 'codegolf', your equivalent initialization vector is 245FZPPAM10FTJQAOHGMYCKWRIXVPES With this setting, baaaaaaaaaaa... should translate to OXVXI NSRPS RGUXY XZVGB QUNJH TWTVD JNPSI TBWKJ XCVNR IUUVK LJWXV OMCGL VQOKD TVJVW HCFZF DBDQS FYECN SDTPC GESYN OWGNZ WWSYQ WJJBT GVMQM GUUVC XZNCV EPGLM MCNHY KLRJC LISZZ PTYIZ GIEUP OPZUI DPZZZ ULXFZ ONGRI WETGU CICMT KKQBW ZJMNL BZSLJ TLMGR RMZDZ BCNGM RYRGJ MKXRF JKQGG PYZFD UUZRE EIKPD OFUPE XODND DFXKY OHXHX ODWDC SXFPV. This should fully test a double stepping scenario.

You may assume the Initialization vector will be valid. Rotors will be in required range, no letter will be used in multiple plugs, etc. Only Reflector B will be used.

All needed info (rotor wirings etc...) must be included in your program, not fetched from an outside source. Most details you need are on wikipedia.

Shortest code wins.

\$\endgroup\$
12
  • 5
    \$\begingroup\$ This question is missing a specification of the procedure for encrypting the text. \$\endgroup\$
    – feersum
    Commented Feb 2, 2015 at 20:28
  • \$\begingroup\$ The encryption details are specified in the Wikipedia links specified, as well as elsewhere on the web. What details would you like put here? \$\endgroup\$
    – captncraig
    Commented Feb 2, 2015 at 20:30
  • 2
    \$\begingroup\$ @CMP All details necessary to compete in the challenge. Challenge should be self-contained. \$\endgroup\$ Commented Feb 2, 2015 at 20:31
  • 5
    \$\begingroup\$ (To be clear, I don't think Enigma encryption is too much for an interesting code golf, but I also think the relevant information can be condensed sufficiently to fit nicely into the challenge spec, and you'd still have a much shorter specification than some other challenges. Just saying, if it doesn't fit in the challenge body, it's probably too elaborate to begin with.) \$\endgroup\$ Commented Feb 2, 2015 at 20:48
  • 2
    \$\begingroup\$ More than an exact spec, I'd like to see a well-written reference implementation. \$\endgroup\$
    – xnor
    Commented Feb 2, 2015 at 22:40

0

Browse other questions tagged or ask your own question.