EnigmaMachine
Enigma.EnigmaMachine
— MethodEnigmaMachine()
Return a EnigmaMachine in the starting position: Rotors I,II,III, UKW A and rotor positions 1,1,1 (A,A,A)
Enigma.EnigmaMachine
— MethodEnigmaMachine(r1::Int, r2::Int, r3::Int, ukw::Int; p1=1, p2=1, p3=1)
Creates an EnigmaMachine with the following setting:
Rotor ids from left to right: r1, r2, r3
r1=1 would be setting the left most rotor to the rotor I
The reflector ( = ukw = Umkehrwalze) is 1,2,3 as well and correspond to the ukws A,B and C
Additionally the rotor positions can be set using p1,p2 and p3 for the three rotors
Return the created EnigmaMachine
Enigma.set_rotors!
— Methodset_rotors!(enigma::EnigmaMachine, r1, r2, r3)
Set the rotors of enigma to r1, r2 and r3 from left to right.
Enigma.set_ukw!
— Methodset_ukw!(enigma::EnigmaMachine, ukw)
Set the reflector (=Umkehrwalze = UKW) of the enigma. Currently ukw can be 1,2,3 for UKW A, UKW and UKW C
Enigma.set_rotor_positions!
— Methodset_rotor_positions!(enigma::EnigmaMachine, p1::Int, p2::Int, p3::Int)
Set the rotor positions from left to right.
Enigma.set_plugboard!
— Methodset_plugboard!(enigma::EnigmaMachine, setting::Vector{Tuple{Int,Int}})
Change the plugboard of the enigma and set it to the new setting.
[(1,2), (3,4)]
would mean that there are two plugs one connecting A and B and one connecting C and D.
See also set_plugboard(enigma::EnigmaMachine, setting::String)
Enigma.set_plugboard!
— Methodset_plugboard!(enigma::EnigmaMachine, setting::String)
Change the plugboard of the enigma and set it to the new setting.
AB BC
would mean that there are two plugs one connecting A and B and one connecting C and D.
See also set_plugboard(enigma::EnigmaMachine, setting::Vector{Tuple{Int,Int}})
Enigma.encode!
— Methodencode!(enigma::EnigmaMachine, s::String; input_validation=true, output_style=:enigma)
If all chars in the string are uppercase letters (so no spaces) then input_validation
can be set to false for a bit speed up.
The default output consists of blocks of five letters. If you don't want the spaces you can set output_style=false
.
Return the string encoded with the enigma.
Enigma.decode!
— Methoddecode!(enigma::EnigmaMachine, s::String; input_validation=true, output_style=:enigma)
Does the same as encode ;)
Enigma.enigma_styled_text
— Methodenigma_styled_text(text::String)
Return creates an enigma styled text which means it replaces all chars which are not letters and makes them uppercase. It also makes blocks of five letters for better or worse readability :D
Bombe
Enigma.BombeMachine
— MethodBombeMachine(secret::String, hint::String)
Return a Bombe with a given secret and a hint.
Enigma.enable_ambiguous!
— Methodenable_ambiguous!(bombe::BombeMachine)
Be sure that the actual message gets found. This takes often much longer and uses lots of RAM :/
I would say most of the time it is not necessary.
Enigma.disable_ambiguous!
— Methoddisable_ambiguous!(bombe::BombeMachine)
If you enabled ambiguous by mistake and want to disable it again ;)
Enigma.set_possible_rotors!
— Methodset_possible_rotors!(bombe::BombeMachine, rotor_1, rotor_2, rotor_3)
Set the rotors that should be checked. Each rotor can be either an integer or a vector of integers (or range).
i.e set_possible_rotors!(bombe::BombeMachine, 1, 2:3, [4,5])
Enigma.set_possible_rotor_positions!
— Methodset_possible_rotor_positions!(bombe::BombeMachine, rp1, rp2, rp3)
Set the rotor positions that should be checked. Each rotor position can be either an integer or a vector of integers (or range).
i.e set_possible_rotor_positions!(bombe::BombeMachine, 1, 1:26, [20,22,25])
`
Enigma.set_possible_ukws!
— Methodset_possible_ukws!(bombe::BombeMachine, ukws)
Set the possible reflectors. ukws
can be a single one or a vector.
Enigma.set_possible_hint_positions!
— Methodset_possible_hint_positions!(bombe::BombeMachine, hint_positions)
Set the positions in the secret the hint might appeared.
i.e if you're sure it's the first word you can use set_possible_hint_positions!(bombe::BombeMachine, 1)
or
if you know that it is at least in the beginning you can use something like set_possible_hint_positions!(bombe::BombeMachine, 1:20)
.
Enigma.set_hint!
— Methodset_hint!(bombe::BombeMachine, hint::String)
This changes the hint used for cracking.
Enigma.set_secret!
— Methodset_secret!(bombe::BombeMachine, secret::String)
This changes the secret used for cracking.
Enigma.run_cracking
— Methodrun_cracking(bombe::BombeMachine; log=true)
Start the cracking process.
Does not give you all possibilities if you haven't run enable_ambiguous!
but this is normally not reasonable.
Return possible enigma settings to understand the secret message.