/// <summary> /// Constructor, setting up the encoder /// </summary> /// <param name="ukwType">Selected UKW Type</param> /// <param name="rotors">Selected rotors</param> /// <param name="rotorPositions">Starting position of each rotor</param> /// <param name="plugboard">All plugboard modifications</param> public Enigma_I(UkwType ukwType, Rotor[] rotors, int[] rotorPositions, Dictionary<char, char> plugboard) { if (ukwType == null) { throw new NullReferenceException("ukwType can't be null"); } if (rotors == null) { throw new NullReferenceException("rotors can't be null"); } if (rotorPositions == null) { throw new NullReferenceException("rotorPositions can't be null"); } if (plugboard == null) { throw new NullReferenceException("plugboard can't be null"); } this.ukwType = ukwType; this.rotors = rotors; this.rotorPositions = rotorPositions; this.plugboard = plugboard; fillRotorsAndUkwTypes(); }
private static IEnigmaEncoder selectEnigmaEncoder(string enigmaEncoderType, UkwType ukwType, Rotor[] rotors, int[] rotorPositions, Dictionary<char, char> plugboard) { IEnigmaEncoder enigmaEncoder = null; switch (enigmaEncoderType) { case "Enigma_I": enigmaEncoder = new Enigma_I(ukwType, rotors, rotorPositions, plugboard); break; default: throw new ArgumentException("Unknown Enigma encoder type: " + enigmaEncoderType); } return enigmaEncoder; }