Enigma


In [1]:
include("enigma.jl")
nothing

Substitution Cipher


In [2]:
rotor = Rotor([4, 2, 1, 3], [4])
alphabet = ['A', 'C', 'S', 'T']
input = "A CAT SAT AT A CASA"

frames = play_animation(rotor, input, alphabet)
write("substitution.gif", frames)
frames


Out[2]:

Rotating Cipher


In [4]:
rotors = [deepcopy(rotor)]
frames = play_animation(rotors, input, alphabet)
write("rotation.gif", frames)
frames


Out[4]:

Multiple Rotors


In [5]:
rotors = [Rotor([4, 2, 1, 3], [4]), Rotor([2, 4, 3, 1], [4])]
frames = play_animation(rotors, input, alphabet)
write("two_rot.gif", frames)
frames


Out[5]:

Adding a Reflector


In [10]:
plugboard = Plugboard(collect(1:4))
ref = Reflector([2,1,4,3])
enigma = Enigma(plugboard, [deepcopy(rotor),deepcopy(rotor)], ref, alphabet)

rp = render_params=RotorRenderParams(80.0, 50.0, 80.0, 180.0, 8.0, 4.0)
frames = play_animation(enigma, input, render_plugboard=false, render_params=rp)
write("reflector.gif", frames)
frames


Out[10]:

With a Plugboard


In [2]:
rotor = Rotor([4, 2, 1, 3], [4])
alphabet = ['A', 'C', 'S', 'T']
input = "A CAT SAT AT A CASA"

plugboard = Plugboard(collect(1:4))
ref = Reflector([2,1,4,3])
enigma = Enigma(plugboard, [deepcopy(rotor),deepcopy(rotor)], ref, alphabet)

enigma.plugboard = Plugboard([2,1,3,4])
rp = render_params=RotorRenderParams(80.0, 50.0, 80.0, 120.0, 8.0, 4.0)
frames = play_animation(enigma, input, render_params=rp)
write("plugboard.gif", frames)
frames


Out[2]:

Full Enigma


In [6]:
enigma = get_M3_enigma('C', (8,2,4), "PXM", "AB CY ET FQ HZ LG MJ OK US WX")
render_params = RotorRenderParams(80.0, 50.0, 10.0, 90.0, 4.0, 2.5)
frames = play_animation(enigma, "ULIUZE EAZ MAIEKMU", render_params=render_params)
write("enigma.gif", frames)
frames


Out[6]:

In [ ]:


In [ ]: