Пример #1
0
            /// <summary>
            ///
            /// Question 14
            ///
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public static string Decode(string str)
            {
                // Why does this work? It is a simle one to one direct mapping.
                // Mapping the resulting chars back to originals is simply done
                // by encoding again.
                string resultStr = AtbashCipher.Encode(str).Replace(" ", "");

                return(resultStr);
            }
        public void Atbash()
        {
            AtbashCipher cipher = new AtbashCipher();

            const string plaintext  = "Abcdefghijklmnopqrstuvwxyz";
            const string ciphertext = "Zyxwvutsrqponmlkjihgfedcba";

            Assert.AreEqual(ciphertext, cipher.Encrypt(plaintext));
            Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext));
        }
Пример #3
0
 public void Decode_with_no_spaces()
 {
     Assert.Equal("anobstacleisoftenasteppingstone", AtbashCipher.Decode("zmlyhgzxovrhlugvmzhgvkkrmthglmv"));
 }
Пример #4
0
 public void Decode_with_too_many_spaces()
 {
     Assert.Equal("exercism", AtbashCipher.Decode("vc vix    r hn"));
 }
Пример #5
0
 public void Decode_all_the_letters()
 {
     Assert.Equal("thequickbrownfoxjumpsoverthelazydog", AtbashCipher.Decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"));
 }
Пример #6
0
 public void Decode_numbers()
 {
     Assert.Equal("testing123testing", AtbashCipher.Decode("gvhgr mt123 gvhgr mt"));
 }
Пример #7
0
 public void Decode_exercism()
 {
     Assert.Equal("exercism", AtbashCipher.Decode("vcvix rhn"));
 }
Пример #8
0
 public void Encode_deep_thought()
 {
     Assert.Equal("gifgs rhurx grlm", AtbashCipher.Encode("Truth is fiction."));
 }
Пример #9
0
 public void Encode_numbers()
 {
     Assert.Equal("gvhgr mt123 gvhgr mt", AtbashCipher.Encode("Testing,1 2 3, testing."));
 }
Пример #10
0
 public void Encode_mindblowingly()
 {
     Assert.Equal("nrmwy oldrm tob", AtbashCipher.Encode("mindblowingly"));
 }
Пример #11
0
 public void Encode_spaces()
 {
     Assert.Equal("lnt", AtbashCipher.Encode("O M G"));
 }
Пример #12
0
 public void Encode_no()
 {
     Assert.Equal("ml", AtbashCipher.Encode("no"));
 }
Пример #13
0
 public void Encode_yes()
 {
     Assert.Equal("bvh", AtbashCipher.Encode("yes"));
 }
 public AtbashCipherTests()
 {
     this.atbashCipher = new AtbashCipher(new ValiatorAndConverter());
 }