Java Enigma Simulator


Interactive command line mode

With the program parameter cli the application will enter the interactive command line mode where it asks for the user input.

Example:
java -jar enigma.jar cli
--------------------------------
Welcome to Enigma Simulator v0.9
--------------------------------
This are the supported rotors:
   I ([E]KMFLGDQVZNTOWYHXUSPAIBRCJ) pos=1(A)
   II ([A]JDKSIRUXBLHWTMCQGZNPYFVOE) pos=1(A)
   III ([B]DFHJLCPRTXVZNYEIWGAKMUSQO) pos=1(A)
   IV ([E]SOVPZJAYQUIRHXLNFTGKDCMWB) pos=1(A)
   V ([V]ZBRGITYUPSDNHLXAWMJQOFECK) pos=1(A)
   VI ([J]PGVOUMFYQBENHZRDKASXLICTW) pos=1(A)
   VII ([N]ZJHGRCXMYSWBOUFAIVLPEKQDT) pos=1(A)
   VIII ([F]KQHTLXOCBJSPDZRAMEWNIUYGV) pos=1(A)
   I/N ([W]TOKASUYVRBXJHQCPZEFMDINLG) pos=1(A)
   II/N ([G]JLPUBSWEMCTQVHXAOFZDRKYNI) pos=1(A)
   III/N ([J]WFMHNBPUSDYTIXVZGRQLAOEKC) pos=1(A)
   IV/N ([E]SOVPZJAYQUIRHXLNFTGKDCMWB) pos=1(A)
   V/N ([H]EJXQOTZBVFDASCILWPGYNMURK) pos=1(A)
   I/D ([L]PGSZMHAEOQKVXRFYBUTNICJDW) pos=1(A)
   II/D ([S]LVGBTFXJQOHEWIRZYAMKPCNDU) pos=1(A)
   III/D ([C]JGDPSHKTURAWZXFMYNQOBVLIE) pos=1(A)
   I/K ([P]EZUOHXSCVFMTBGLRINQJWAYDK) pos=1(A)
   II/K ([Z]OUESYDKFWPCIQXHMVBLGNJRAT) pos=1(A)
   III/K ([E]HRVXGAOBQUSIMZFLYNWKTPDJC) pos=1(A)
   I/R ([J]GDQOXUSCAMIFRVTPNEWKBLZYH) pos=1(A)
   II/R ([N]TZPSFBOKMWRCJDIVLAEYUXHGQ) pos=1(A)
   III/R ([J]VIUBHTCDYAKEQZPOSGXNRMWFL) pos=1(A)
   I/T ([K]PTYUELOCVGRFQDANJMBSWHZXI) pos=1(A)
   II/T ([U]PHZLWEQMTDJXCAKSOIGVBYFNR) pos=1(A)
   III/T ([Q]UDLYRFEKONVZAXWHMGPJBSICT) pos=1(A)
   IV/T ([C]IWTBKXNRESPFLYDAGVHQUOJZM) pos=1(A)
   V/T ([U]AXGISNJBVERDYLFZWTPCKOHMQ) pos=1(A)
   VI/T ([X]FUZGALVHCNYSEWQTDMRBKPIOJ) pos=1(A)
   VII/T ([B]JVFTXPLNAYOZIKWGDQERUCHSM) pos=1(A)
   VIII/T ([Y]MTPNZHWKODAJXELUQVGCBISFR) pos=1(A)
   A ([E]JMZALYXVBWFCRQUONTSPIKHGD) pos=1(A)
   B ([Y]RUHQSLDPXNGOKMIEBFZCWVJAT) pos=1(A)
   C ([F]VPJIAOYEDRZXWGCTKUQSBNMHL) pos=1(A)
   D ([I]METCGFRAYSQBZXWLHKDVUPOJN) pos=1(A)
   K ([I]METCGFRAYSQBZXWLHKDVUPOJN) pos=1(A)
   N ([M]OWJYPUXNDSRAIBFVLKZGQCHET) pos=1(A)
   R ([Q]YHOGNECVPUZTFDJAXWMKISRBL) pos=1(A)
   T ([G]EKPBTAUMOCNILJDXZYFHWVQSR) pos=1(A)
   -NONE- ([A]BCDEFGHIJKLMNOPQRSTUVWXYZ) pos=1(A)
   EW/K ([Q]WERTZUIOASDFGHJKPYXCVBNML) pos=1(A)
   EW/D ([J]WULCMNOHPQZYXIRADKEGVBTSF) pos=1(A)
   EW/R ([Q]WERTZUIOASDFGHJKPYXCVBNML) pos=1(A)
   EW/T ([K]ZROUQHYAIGBLWVSTDXFPNMCJE) pos=1(A)
--------------------------------
Enter the reflector (default is 'B'):
Enter the rotors (from slow rotor to fast rotor) separated by - (default is 'I-II-III'):
Enter the Entry Wheel (default is '-NONE-'):
Enter the key (starting position) for the reflector (default is 'A'):
Enter the key (starting position) for the rotors (default is 'AAA'):
Enter ring position (default is ''):
Enter characters to swap (plug board) with format 'AF-BY' (default is none):
Print all steps? (Debug mode 'y' or 'n') (default is 'n'):
--------------------------------
Enter message: secret
--------------------------------
Starting configuration:
   reflector   : B ([Y]RUHQSLDPXNGOKMIEBFZCWVJAT) pos=1(A)
   slow rotor  : I ([E]KMFLGDQVZNTOWYHXUSPAIBRCJ) pos=1(A)
   middle rotor: II ([A]JDKSIRUXBLHWTMCQGZNPYFVOE) pos=1(A)
   fast rotor  : III ([B]DFHJLCPRTXVZNYEIWGAKMUSQO) pos=1(A)
   plug board  : ABCDEFGHIJKLMNOPQRSTUVWXYZ
--------------------------------
output:
JLEURR
						

Command line arguments

The program can be called with parameters so that no further input is required to get the ecryption result.
  • reflector=[x] specifies the reflector to use. [x] can be on of A,B,C,D,K,N,R,T. If this parameter is missing the default is reflector B.
  • rotors=[r1]-[r2]-[r3]-... specifies the rotors to use from slow rotor (left) to fast rotor (right), separated by a '-'. If this parameter is missing the default is rotors are I-II-III.
  • etw=[x] specifies the entry wheel to use. If this parameter is missing the default entry wheel is 'ETW' (which does not modify the input/output).
  • rkey=[x] specifies the position of the reflector (typically always 'A'). If this parameter is missing the default position is 'A'.
  • key=[x1x2x3...] specifies the starting position of the rotors (same order as the rotors) where [x] must be a letter in the range A-Z. If this parameter is missing the default position is 'AAA'. PLEASE NOTE: the number of positions must match the number of rotors!
  • ring=[x1]-[x2]-[x3]-... specifies the ring config of the rotors (same order as the rotors) where [x] must be a number in the range 01-26. If this parameter is missing the default ring is '01-01-01'. PLEASE NOTE: the number of ring configs must match the number of rotors!
  • plug=[p1]-[p2]-[p3]-... specifies the plug board (that are the characters to swap) in the format 'AF-BX-...'. If this parameter is missing no characters will be swapped.
  • message=[m] specifies the message to encrypt/decrypt. PLEASE NOTE: avoid spaces in the message because a space indicates a new program argument. If this parameter is missing the application will ask for input.
  • debug if this parameter is set the program will print all steps and intermediate results.


Example:
java -jar enigma.jar reflector=B rotors=IV-III-V-I key=FRXA plug=BK-DU-KZ message=SECRET debug
Starting configuration:
   reflector   : B ([Y]RUHQSLDPXNGOKMIEBFZCWVJAT) pos=1(A)
   slow rotor  : IV (ESOVP[Z]JAYQUIRHXLNFTGKDCMWB) pos=6(F)
   middle rotor: III (BDFHJLCPRTXVZNYEI[W]GAKMUSQO) pos=18(R)
   middle rotor: V (VZBRGITYUPSDNHLXAWMJQOF[E]CK) pos=24(X)
   fast rotor  : I ([E]KMFLGDQVZNTOWYHXUSPAIBRCJ) pos=1(A)
   plug board  : AZCUEFGHIJBLMNOPQRSTDVWXYK
--------------------------------
advance rotor: I (E[K]MFLGDQVZNTOWYHXUSPAIBRCJ) pos=2(B)
input='S' I:S->O V:O->G III:G->B IV:B->E B:E->Q IV:Q->Y III:Y->Q V:Q->P I:P->G
 output='G'
--------------------------------
advance rotor: I (EK[M]FLGDQVZNTOWYHXUSPAIBRCJ) pos=3(C)
input='E' I:E->B V:B->F III:F->D IV:D->T B:T->Z IV:Z->V III:V->E V:E->F I:F->N
 output='N'
--------------------------------
advance rotor: I (EKM[F]LGDQVZNTOWYHXUSPAIBRCJ) pos=4(D)
input='C' I:C->D V:D->Y III:Y->N IV:N->O B:O->M IV:M->H III:H->X V:X->L I:L->J
 output='J'
--------------------------------
advance rotor: I (EKMF[L]GDQVZNTOWYHXUSPAIBRCJ) pos=5(E)
input='R' I:R->E V:E->C III:C->J IV:J->S B:S->F IV:F->P III:P->B V:B->K I:K->I
 output='I'
--------------------------------
advance rotor: I (EKMFL[G]DQVZNTOWYHXUSPAIBRCJ) pos=6(F)
input='E' I:E->U V:U->Z III:Z->R IV:R->X B:X->J IV:J->X III:X->I V:I->Z I:Z->V
 output='V'
--------------------------------
advance rotor: I (EKMFLG[D]QVZNTOWYHXUSPAIBRCJ) pos=7(G)
input='T' I:T->D V:D->Y III:Y->N IV:N->O B:O->M IV:M->H III:H->X V:X->L I:L->R
 output='R'
--------------------------------
final rotor positions:
   IV (ESOVP[Z]JAYQUIRHXLNFTGKDCMWB) pos=6(F)
   III (BDFHJLCPRTXVZNYEI[W]GAKMUSQO) pos=18(R)
   V (VZBRGITYUPSDNHLXAWMJQOF[E]CK) pos=24(X)
   I (EKMFLG[D]QVZNTOWYHXUSPAIBRCJ) pos=7(G)
--------------------------------
output:
GNJIVR
					
My other projects: