Exemplo n.º 1
0
        public void CheckFiveAWithRingBGivesCorrectOutput()
        {
            //With the rotors I, II, III (from left to right), wide B-reflector, all ring settings in B-position, and start position AAA, typing AAAAA will produce the encoded sequence EWTYX.
            Scrambler3 s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.B, Letters.A), Rotor.RotorII(Letters.B, Letters.A), Rotor.RotorIII(Letters.B, Letters.A));

            Letters l;

            l = s.GetOutput(Letters.A);
            Assert.That(l, Is.EqualTo(Letters.E));

            l = s.GetOutput(Letters.A);
            Assert.That(l, Is.EqualTo(Letters.W));

            l = s.GetOutput(Letters.A);
            Assert.That(l, Is.EqualTo(Letters.T));

            l = s.GetOutput(Letters.A);
            Assert.That(l, Is.EqualTo(Letters.Y));

            l = s.GetOutput(Letters.A);
            Assert.That(l, Is.EqualTo(Letters.X));
        }
Exemplo n.º 2
0
        public void CheckGandPReverseWithSameStartingConfiguration()
        {
            Scrambler s;
            Letters   l;

            s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.A, Letters.A), Rotor.RotorII(Letters.A, Letters.A), Rotor.RotorIII(Letters.A, Letters.Z));

            l = s.GetOutput(Letters.G);
            Assert.That(l, Is.EqualTo(Letters.P));

            s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.A, Letters.A), Rotor.RotorII(Letters.A, Letters.A), Rotor.RotorIII(Letters.A, Letters.Z));

            l = s.GetOutput(Letters.P);
            Assert.That(l, Is.EqualTo(Letters.G));
        }
Exemplo n.º 3
0
        public void CheckEncypheredMessageDecyphers()
        {
            Scrambler s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.A, Letters.A), Rotor.RotorII(Letters.A, Letters.A), Rotor.RotorIII(Letters.A, Letters.A));

            Letters[] expectedPlaintext = LetterMapper.CreateLettersArray("THISISMYTESTMESSAGE");

            Letters[] cyphertext = LetterMapper.CreateLettersArray("OPGNDXOEHCJEXBEDDUO");

            Letters[] plaintext = new Letters[cyphertext.Length];

            for (int i = 0; i < cyphertext.Length; i++)
            {
                plaintext[i] = s.GetOutput(cyphertext[i]);
            }

            Assert.That(plaintext, Is.EqualTo(expectedPlaintext));
        }
Exemplo n.º 4
0
        public void CheckEncypheredMessageDecyphersWithRolloverAndRingF()
        {
            Scrambler s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.A, Letters.A), Rotor.RotorII(Letters.A, Letters.A), Rotor.RotorIII(Letters.F, Letters.A));

            Letters[] expectedPlaintext = LetterMapper.CreateLettersArray("THISMESSAGEWILLCAUSEROLLOVER");

            Letters[] cyphertext = LetterMapper.CreateLettersArray("UFVWRFXPGFNQBAPWSVNSFXOGCPPK");

            Letters[] plaintext = new Letters[cyphertext.Length];

            for (int i = 0; i < cyphertext.Length; i++)
            {
                plaintext[i] = s.GetOutput(cyphertext[i]);
            }

            Assert.That(plaintext, Is.EqualTo(expectedPlaintext));
        }
Exemplo n.º 5
0
        public void CheckEncypheredMessageDecyphersWithMoreRollover()
        {
            Scrambler s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.A, Letters.A), Rotor.RotorII(Letters.A, Letters.A), Rotor.RotorIII(Letters.A, Letters.A));

            Letters[] expectedPlaintext = LetterMapper.CreateLettersArray("BAUSSRLQONWLBSZPPAORUKKJPRUYZNOLRKKHFMLJRAVSPOJVTPGHRBLEPRVPZMZYNTBWBISKQUBDWIENKKPHHDZIXBUSROMKSBITTAKICWDIFWPINAMXTHWOOQWZWCEIPGKDRMIGIVRSLCEQGHGKXLCXARNZXWGJSICHWOVIUGPLUVNYYQLOONRJJRQNPSIHYMQXXMUOEEKQPVUFLCPUFFJLFWIDHTVBHFHLCJMKWYZWPJHCOBHYXJEOKOSHCMABEVUNHEFYBMFPQPHVQPLFSYFNESRLWBOIBUEMZHLAZFRJEYGVTSCZTKRTRVOLZEFNZPCYDPCNIYQEEJBNWWXSXSRIYAIVFOUVMBOGQZVWMPYVOAUBIOZWFZVVLGKMCOZMWCSCOXWNJRPPVVUUPRURVIWXIATKFHUTXJSNMHCQLKGTTKAFBTORKWHTUCMTXQJFKORXORVINKXGUNCALBJQHQQEWFCQQMBJYWFAWVSZSMFLHUBZEQYEGPBAXMNYVKJBXRMTLBVZTHPQBRPPSFMQRDLJLVUYUHQRYTEUURQSOGYUAEIJQMXSXFJFTLSOPYJLULMGJGXYBPVJHZAGFIBEPUKKEJMVQMGQMKFMZKXGRKGTSYAZLPUDRRWSOHWC");

            Letters[] cyphertext = LetterMapper.CreateLettersArray("ADFNBTUOMHCRANIBRLEVTHRCQJCBVYGUEOMGUKCDTSUQJCUUOFNEKPBXHMQJKEUIXENMCLAHIWCCTJMSETLDMZWJWIYCCNWUHHHFNBWMBITTGETBVFAFRWUTYMQUPZHHRRHYWEJTBAMKJLILXFAZKDHVLDCXMUXDIQKUAXMUXRFYRDWKFFFHFAAQBKLTJNLBRQYUMXDAQZUDTGWGRGITLHPXPDMVOMDWOVBMKRGTRXUKNEDMNILPHYGNJJVOPXZRPRWAQSXERTQVXFPXVVZNTVXAYKLMVUEYZGQOLQSBEVYLRFOQSDUUMLPKAXLWRNBCMCNEFQMERXFIDSNGLBAMVBYOFVUOGNTOLSFKCROCEGOELRWSZTHDNHHISITKKDDUVEKLLDEGCPHWERBOLVTPQQVFBHDDYDSFDYKQLQTCJBUQYGVHVMSOOEDCEUBBPFQPGNIMTTZNSNDTFPMCODOLRZKXHBNTDTQYDNVZZBATJVLQVSVBGVEDBRWQAQUUPTTDPSGZJUWXVOUHNWQMQXHZABKGNUVPELJHVGORJXDYDFINOOYQAFKYORUPEBKNSCOARUUTSAGLWGILXMEPXDYJMSHXQOQRNAQYVJTETTZZPTQUEXYREZOXJTFCJNPK");

            Letters[] plaintext = new Letters[cyphertext.Length];

            for (int i = 0; i < cyphertext.Length; i++)
            {
                plaintext[i] = s.GetOutput(cyphertext[i]);
            }

            Assert.That(plaintext, Is.EqualTo(expectedPlaintext));
        }
Exemplo n.º 6
0
        public void CheckEncypheredMessageDecyphersWithRollover()
        {
            Scrambler s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorI(Letters.A, Letters.A), Rotor.RotorII(Letters.A, Letters.A), Rotor.RotorIII(Letters.A, Letters.A));

            Letters[] expectedPlaintext = LetterMapper.CreateLettersArray("THISISALONGMESSAGETOTESTROLLOVERINTHEROTORS");

            Letters[] cyphertext = LetterMapper.CreateLettersArray("OPGNDXCGMHUNLNECJZGJUPLWOVMOJFUJWQXGSUDEJVY");

            Letters[] plaintext = new Letters[cyphertext.Length];

            for (int i = 0; i < cyphertext.Length; i++)
            {
                plaintext[i] = s.GetOutput(cyphertext[i]);
            }

            Assert.That(plaintext, Is.EqualTo(expectedPlaintext));
        }
Exemplo n.º 7
0
        public Letters GetOutput(Letters input)
        {
            Letters output = m_scrambler.GetOutput(input);

            return(output);
        }