Example #1
0
        /// <summary>
        /// Decipher a ciphertext into plaintext.
        /// </summary>
        /// <param name="ciphertext">The ciphertext to decipher.</param>
        /// <returns>The plaintext.</returns>
        public string Decipher(string ciphertext)
        {
            char[][]      digraphs;
            StringBuilder plaintext = new StringBuilder();

            digraphs = CipherMethods.SplitDigraphs(ciphertext);
            for (int i = 0; i <= digraphs.Length; i++)
            {
                plaintext.Append(Decipher(digraphs[i][0], digraphs[i][1]));
            }
            return(plaintext.ToString());
        }
Example #2
0
        /// <summary>
        /// Encipher a plaintext string into ciphertext.
        /// </summary>
        /// <param name="plaintext">The plaintext to encipher.</param>
        /// <returns>The ciphertext.</returns>
        public string Encipher(string plaintext)
        {
            char[][]      digraphs;
            StringBuilder ciphertext = new StringBuilder();

            digraphs = CipherMethods.GenerateDigraphs(plaintext);
            for (int i = 0; i <= digraphs.Length; i++)
            {
                ciphertext.Append(Encipher(digraphs[i][0], digraphs[i][1]));
            }
            return(ciphertext.ToString());
        }