예제 #1
0
        public void SingleCharacterDeCrypt()
        {
            char        expected = 'G';
            NestedRotor enigma   = CreateMultiRotorEnigmaMachine("AAA");
            char        actual   = enigma.Crypt('P');

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void TestMethod1()
        {
            char        expected = 'A';
            NestedRotor enigma   = CreateSingleRotorEnigmaMachine();
            char        actual   = enigma.Crypt('A');

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public string Crypt(string p)
        {
            StringBuilder result = new StringBuilder();

            foreach (char character in p)
            {
                Advance();
                char preSteckeredCharacter  = _plugboard.Translate(character);
                char cryptedCharacter       = _rotors.Crypt(preSteckeredCharacter);
                char postSteckeredCharacter = _plugboard.Translate(cryptedCharacter);
                result.Append(postSteckeredCharacter);
            }
            return(result.ToString());
        }