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