// Will create an Enigma with an empty plugboard, rotors I, II, III and reflector B (wide).
let enigma = Enigma()
// Will output "ILBDA AMTAZ"
let result = enigma.encode("HELLO WORLD")
let enigma = Enigma()
// "HELLO WORLD"
let result = enigma.decode("ILBDA AMTAZ")
To run the example project, clone the repo, and run pod install
from the Example directory first.
// Create a plugboard and add a patch between A and D
let plugboard = Plugboard()
plugboard.addPatch(("A", "D"))
// III rotor. EnigmaKit comes prebuilt with rotors I-VIII
let rotor = Rotor.III
rotor.setting = 5 // Internal ring position
rotor.position = 6 // Outer ring position
// Or initialize your own
let rotor = Rotor(name: "My custom rotor", wiring: "VZBRGITYUPSDNHLXAWMJQOFECK", notch: "QV")
// EnigmaKit comes with reflector A-C (wide) and B-C (thin)
let reflector = Reflector.B
// Or you can create your own reflector
let reflector = Reflector(name: "My custom reflector", wiring: "VZBRGITYUPSDNHLXAWMJQOFECK")
// Create an enigma with your own plugboard, rotors and reflector of choice
let enigma = Enigma(plugboard: Plugboard(), rotors: [Rotor.III, Rotor.IV, Rotor.II], reflector: Reflector.C)
Don't mention the war
EnigmaKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "EnigmaKit"
Joakim Gyllstrรถm, [email protected]
EnigmaKit is available under the MIT license. See the LICENSE file for more info.