예제 #1
0
        private void UpdateSettings()
        {
            StringBuilder sb  = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();

            _settings.CipherKey  = CipherRotors.Aggregate("", (current, r) => String.Concat(current, (char)(r.Position + 65)));
            _settings.ControlKey = ControlRotors.Reverse().Aggregate("", (current, r) => String.Concat(current, (char)(r.Position + 65)));
        }
예제 #2
0
        public int Cipher(int c)
        {
            int temp = c;

            if (_settings.Action == 0)
            {
                temp = CipherRotors.Aggregate(temp, (current, rotor) => rotor.Ciph(current));
            }
            if (_settings.Action == 1)
            {
                temp = CipherRotors.Reverse().Aggregate(temp, (current, rotor) => rotor.DeCiph(current));
            }

            return(temp);
        }