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