public void DecryptWithNullTest() { const string ciphertext = "abbaba"; var cipher = new SimpleSubstitutionCipher(new Alphabet("ab")); cipher.Decrypt(ciphertext, null); }
public void DecryptNullTest() { var key = new SimpleSubstitutionKey(("ab", "ba")); var cipher = new SimpleSubstitutionCipher(new Alphabet("ab")); cipher.Decrypt(null, key); }
public void DecryptWrongKeyTest3() { var key = new SimpleSubstitutionKey(("abcd", "badc")); const string ciphertext = "aacabc"; var cipher = new SimpleSubstitutionCipher(new Alphabet("abc")); cipher.Decrypt(ciphertext, key); }
public void DecryptTest() { var key = new SimpleSubstitutionKey(("ab", "ba")); const string plaintext = "abbaba"; const string ciphertext = "baabab"; var cipher = new SimpleSubstitutionCipher(new Alphabet("ab")); Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext, key)); }
public void AbsorbtionTest() { var encKey = new SimpleSubstitutionKey(("abc", "bca")); var decKey = KeyGenerator.GetSimpleSubstitutionDecryptionKey(encKey); const string plaintext = "abcbabca"; var cipher = new SimpleSubstitutionCipher(new Alphabet("abc")); Assert.AreEqual( plaintext, cipher.Decrypt(cipher.Encrypt(plaintext, encKey), decKey)); }
public void DecryptWrongTextTest() { var key = new SimpleSubstitutionKey(("ab", "ba")); const string ciphertext = "aacabc"; var cipher = new SimpleSubstitutionCipher(new Alphabet("ab")) { IsStrict = false }; Assert.AreEqual("bbcbac", cipher.Decrypt(ciphertext, key)); }
public void DecryptWrongTextStrictTest() { var key = new SimpleSubstitutionKey(("ab", "ba")); const string ciphertext = "aacabc"; var cipher = new SimpleSubstitutionCipher(new Alphabet("ab")) { IsStrict = true }; cipher.Decrypt(ciphertext, key); }
public string Decrypt(string cipherText) { string plainText = cipherText; SimpleSubstitutionCipher simpleSubstitutionCipher = new SimpleSubstitutionCipher(); simpleSubstitutionCipher.SetKey(SIMPLE_SUBSTITUTION_CIPHER_KEY); plainText = simpleSubstitutionCipher.Decrypt(plainText); AffineCipher affineCipher = new AffineCipher(); affineCipher.SetKeys(new int[] { AFFINE_CIPHER_KEY_A, AFFINE_CIPHER_KEY_B }); plainText = affineCipher.Decrypt(plainText); CaesarCipher caesarCipher = new CaesarCipher(); caesarCipher.SetKey(CAESAR_CIPHER_KEY); plainText = caesarCipher.Decrypt(plainText); return(plainText); }