コード例 #1
0
        public void TestEncryptionDefaultSettings()
        {
            var    machine = new MyEnigmaMachine();
            string cypher  = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

            Assert.AreEqual("FUVEPUMWARVQKEFGHGDIJFMFXI", cypher);
            machine.ResetRotors();
            cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            Assert.AreEqual("FUVEPUMWARVQKEFGHGDIJFMFXI", cypher);
            machine.ResetRotors();
            cypher = machine.Encrypt("FUVEPUMWARVQKEFGHGDIJFMFXI");
            Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", cypher);
        }
コード例 #2
0
        public void TestEncryptionRingStartingLettertSettings()
        {
            var machine = new MyEnigmaMachine();

            machine.SetCurrentRotorRingLetters(new[] { 'F', 'R', 'Q' });
            string cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

            Assert.AreEqual("MHHKTNIROWJNYMNWKHMVEZQHWU", cypher);
            machine.ResetRotors();
            cypher = machine.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            Assert.AreEqual("MHHKTNIROWJNYMNWKHMVEZQHWU", cypher);
            machine.ResetRotors();
            cypher = machine.Encrypt("MHHKTNIROWJNYMNWKHMVEZQHWU");
            Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", cypher);
        }
コード例 #3
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);
        }