Exemple #1
0
        public string EncryptMessage(string message)
        {
            StringBuilder cipherMessage = new StringBuilder();
            char          curChar;

            foreach (char c in message)
            {
                curChar = etw.CipherInput(c);
                curChar = rightRotor.DeflectAndCipher(curChar);
                curChar = rightRotor.IsInTurnover() ? middleRotor.DeflectAndCipher(curChar) : middleRotor.CipherInput(curChar);
                curChar = middleRotor.IsInTurnover() ? leftRotor.DeflectAndCipher(curChar) : leftRotor.CipherInput(curChar);
                curChar = ukw.CipherInput(curChar);
                curChar = leftRotor.CipherOutput(curChar);
                curChar = middleRotor.CipherOutput(curChar);
                curChar = rightRotor.CipherOutput(curChar);
                curChar = etw.CipherOutput(curChar);

                cipherMessage.Append(curChar);
            }

            return(cipherMessage.ToString());
        }