Esempio n. 1
0
        public void CheckEntryWheelGivesCorrectOutputValue()
        {
            EntryWheel e = new EntryWheel(LetterMapper.CreateLettersArray("QWERTZUIOASDFGHJKPYXCVBNML"));

            Letters result = e.GetOutput(Letters.Q);

            Assert.That(result, Is.EqualTo(Letters.A));
        }
Esempio n. 2
0
 public Scrambler(IReflector reflector, Rotor additionalRotor, Rotor rotorL, Rotor rotorM, Rotor rotorR, EntryWheel entryWheel)
 {
     m_reflector       = reflector;
     m_additionalRotor = additionalRotor;
     m_rotorL          = rotorL;
     m_rotorM          = rotorM;
     m_rotorR          = rotorR;
     m_entryWheel      = entryWheel;
 }
Esempio n. 3
0
        public EnigmaB(string rotorSettings, string ringSettings)
        {
            var rotorFactory = new EnigmaBRotorFactory();

            etw = new EntryWheel("ABCDEFGHIJKLMNOPQRSTUVXYZÅÄÖ", "ABCDEFGHIJKLMNOPQRSTUVXYZÅÄÖ");
            ukw = new Reflector("ABCDEFGHIJKLMNOPQRSTUVXYZÅÄÖ", "LDGBÄNCPSKJAVFZHXUIÅRMQÖOTEY");

            string[] rotorTypes = rotorSettings.Split(' ');
            char[]   ringTypes  = ringSettings.Split(' ').Select(x => x[0]).ToArray();

            leftRotor   = rotorFactory.CreateRotor(rotorTypes[0], ringTypes[0]);
            middleRotor = rotorFactory.CreateRotor(rotorTypes[1], ringTypes[1]);
            rightRotor  = rotorFactory.CreateRotor(rotorTypes[2], ringTypes[2]);
        }
Esempio n. 4
0
        public EnigmaZ(string rotorSettings, string ringSettings)
        {
            var rotorFactory = new EnigmaZRotorFactory();

            etw = new EntryWheel("1234567890", "1234567890");

            string[] rotorTypes = rotorSettings.Split(' ');
            char[]   ringTypes  = ringSettings.Split(' ').Select(x => x[0]).ToArray();

            leftRotor   = rotorFactory.CreateRotor(rotorTypes[0], ringTypes[0]);
            middleRotor = rotorFactory.CreateRotor(rotorTypes[1], ringTypes[1]);
            rightRotor  = rotorFactory.CreateRotor(rotorTypes[2], ringTypes[2]);

            ukw = new Rotor("1234567890", "5079183642", "0", '0');
        }
Esempio n. 5
0
 public Scrambler3(Reflector reflector, Rotor rotorL, Rotor rotorM, Rotor rotorR)
     : base(reflector, Rotor.RotorPassThrough(), rotorL, rotorM, rotorR, EntryWheel.EntryWheelDirect())
 {
 }
Esempio n. 6
0
 public Scrambler4(Reflector reflector, Rotor additionalRotor, Rotor rotorL, Rotor rotorM, Rotor rotorR)
     : base(reflector, additionalRotor, rotorL, rotorM, rotorR, EntryWheel.EntryWheelDirect())
 {
 }
Esempio n. 7
0
 public void CheckEntryWheelSucceedsWithMapDirect()
 {
     EntryWheel e = new EntryWheel(LetterMapper.CreateLettersArray("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
 }
Esempio n. 8
0
 public void CheckEntryWheelSucceedsWithMapQwertz()
 {
     EntryWheel e = new EntryWheel(LetterMapper.CreateLettersArray("QWERTZUIOASDFGHJKPYXCVBNML"));
 }
Esempio n. 9
0
 public ScramblerK(ReflectorK reflector, Rotor rotorL, Rotor rotorM, Rotor rotorR, EntryWheel entryWheel)
     : base(reflector, Rotor.RotorPassThrough(), rotorL, rotorM, rotorR, entryWheel)
 {
 }
Esempio n. 10
0
        public void CheckInstructionManualMessage()
        {
            //http://www.cryptomuseum.com/crypto/enigma/k/railway.htm
            //http://www.cryptomuseum.com/crypto/enigma/i/index.htm

            string expectedPlainText = "DEUTSQETRUPPENSINDJETZTINENGLAND";

            // Message Key: JEZA
            // Reflector: ?
            // Wheel order: III I II
            // Ring positions: 26 17 16 13
            // Plug Pairs:
            ScramblerK s = new ScramblerK(ReflectorK.Reflector((Letters)25, Letters.J), Rotor.RotorKIII((Letters)16, Letters.E), Rotor.RotorKI((Letters)15, Letters.Z), Rotor.RotorKII((Letters)12, Letters.A), EntryWheel.EntryWheelQwertz());

            EnigmaK e = new EnigmaK(s);

            string cypherText = "QSZVIDVMPNEXACMRWWXUIYOTYNGVVXDZ";

            string plainText = e.GetOutput(cypherText);

            Assert.That(plainText, Is.EqualTo(expectedPlainText));
        }