示例#1
0
        public char Encode(int inputChar)
        {
            int input          = inputChar;
            int afterRight1    = RightRotor.Encode(input, true);
            int afterCenter1   = CenterRotor.Encode(afterRight1, true);
            int afterLeft1     = LeftRotor.Encode(afterCenter1, true);
            int afterReflector = Reflector.Reflect(afterLeft1);
            int afterLeft2     = LeftRotor.Encode(afterReflector, false);
            int afterCenter2   = CenterRotor.Encode(afterLeft2, false);
            int afterRight2    = RightRotor.Encode(afterCenter2, false);

            return(Convert.ToChar(afterRight2 + 65));
        }
示例#2
0
        public void ShiftRotors()
        {
            if (LeftRotor.ShouldRotate | CenterRotor.ShouldRotate)
            {
                LeftRotor.Rotate();
            }

            if (CenterRotor.ShouldRotate | RightRotor.ShouldRotate)
            {
                CenterRotor.Rotate();
            }

            RightRotor.Rotate();
        }