예제 #1
0
        public void TestFullParameters()
        {
            var machine = new MyEnigmaMachine();

            machine.SetupRotors(new[] { new RotorInfo("IV", 'M', 'F'), new RotorInfo("V", 'C', 'U'), new RotorInfo("II", 'W', 'T') });
            machine.SetupPlugboard("ABCKEFGHIJDLNMOPQRSTUZWXYV");
            string cypher = machine.Encrypt("This is a test");

            Assert.AreEqual("Rmxe li c wmua", cypher);
        }
예제 #2
0
        public void TestEncryptionRingOffsetSettings()
        {
            var machine = new MyEnigmaMachine();

            machine.SetupRotors(new[] { new RotorInfo("I", 'A', 'B'), new RotorInfo("II", 'A', 'B'), new RotorInfo("III", 'A', 'B') });

            string cypher = machine.Encrypt("AAAAA");

            Assert.AreEqual("EWTYX", cypher);
            machine.ResetRotors();
            cypher = machine.Encrypt("AAAAA");
            Assert.AreEqual("EWTYX", cypher);
            machine.ResetRotors();
            cypher = machine.Encrypt("EWTYX");
            Assert.AreEqual("AAAAA", cypher);
        }