コード例 #1
0
        public void DecryptNullTest()
        {
            var key = new Key <string>("ABCD");

            var cipher = new VisenereCipher(new Alphabet("ABCD"));

            cipher.Decrypt(null, key);
        }
コード例 #2
0
        public void DecryptWrongKeyTest()
        {
            var key = new Key <string>("abc");

            const string ciphertext = "aabab";

            var cipher = new VisenereCipher(new Alphabet("ab"));

            cipher.Decrypt(ciphertext, key);
        }
コード例 #3
0
        public void DecryptTest()
        {
            const string plaintext  = "CRYPTOISSHORTFORCRYPTOGRAPHY";
            const string ciphertext = "CSASTPKVSIQUTGQUCSASTPIUAQJB";

            var key      = new Key <string>("ABCD");
            var alphabet = new Alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

            var cipher = new VisenereCipher(alphabet);

            Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext, key));
        }
コード例 #4
0
        public void AbsorbtionTest()
        {
            const string plaintext = "CRYPTOISSHORTFORCRYPTOGRAPHY";

            var key      = new Key <string>("ABCD");
            var alphabet = new Alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

            var cipher = new VisenereCipher(alphabet);

            Assert.AreEqual(
                plaintext,
                cipher.Decrypt(cipher.Encrypt(plaintext, key), key));
        }
コード例 #5
0
        public void DecryptWrongTextTest()
        {
            var key = new Key <string>("ab");

            const string ciphertext = "aacabc";

            var cipher = new VisenereCipher(new Alphabet("ab"))
            {
                IsStrict = false
            };

            Assert.AreEqual("abcbbc", cipher.Decrypt(ciphertext, key));
        }
コード例 #6
0
        public void DecryptWrongTextStrictTest()
        {
            var key = new Key <string>("ab");

            const string ciphertext = "aacabc";

            var cipher = new VisenereCipher(new Alphabet("ab"))
            {
                IsStrict = true
            };

            cipher.Decrypt(ciphertext, key);
        }