Exemplo n.º 1
0
 public ScramblerUnitBase(EnigmaSettings settings)
 {
     this.Rotors         = settings.Rotors.ToArray();
     this.RotorPositions = settings.RotorPositions.ToArray();
     this.Reflector      = settings.Reflector;
     this.EntryWheel     = settings.EntryWheel;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for the EnigmaMachine class.
 /// </summary>
 /// <param name="settings">The settings that will be used to initialize this EnigmaMachine.</param>
 public EnigmaMachine(EnigmaSettings settings)
 {
     rotorSet     = settings.RotorSet;
     IsDecrypting = settings.IsDecrypting;
     BlockSize    = settings.BlockSize;
     Name         = settings.Name;
     FileIn       = settings.FileIn;
     FileOut      = GetOutputFilename(settings.FileIn, settings.Name, settings.IsDecrypting);
     InputType    = settings.InputType;
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            bool continueInput = true;

            do
            {
                Console.Clear();
                bool keepSettings = true;

                SetEnigmaSettings();

                do
                {
                    EnigmaSettings machine = new EnigmaSettings(rotorValues, rotorOffsets, reflector, plugboard);
                    //EnigmaSettings machine = new EnigmaSettings(new int[] { 2, 1, 0 }, new int[] { 0, 0, 0 }, Reflectors.ReflectorList[1], "ABCDEFGHIJKLMNOPQRST");
                    string output = "";

                    Console.Clear();
                    Console.WriteLine(machine.ToString());
                    Console.WriteLine("String to encrypt: ");
                    string input = Console.ReadLine().ToUpper();
                    RemoveSpaces(ref input);

                    Console.Clear();
                    Console.WriteLine("Input:\t" + input);

                    foreach (char c in input)
                    {
                        output += machine.DetermineValue(c);
                    }

                    Console.WriteLine("Output:\t" + output);
                    Console.WriteLine("\nPress any [r] to reset machine, Press [e] to continue with settings...");
                    string key = Console.ReadKey().KeyChar.ToString().ToUpper();
                    if (key == "R")
                    {
                        keepSettings = false;
                    }
                    else if (key == "E")
                    {
                        continueInput = false;
                        break;
                    }
                } while (keepSettings);
            } while (continueInput);

            Console.WriteLine("\n\nEnigma Machine Shutting Down........");
            Console.ReadKey();
        }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="machineSettings"></param>
 public EnigmaMachineBase(EnigmaSettings machineSettings)
 {
     PlugBoard     = machineSettings.PlugBoard;
     ScramblerUnit = new ScramblerUnitBase(machineSettings);
 }