Beispiel #1
0
        public void EncryptWrongTextStrictTest()
        {
            const string plaintext = "aa,cabc";
            var          cipher    = new CaesarCipher(Alphabets.EnglishLower)
            {
                IsStrict = true
            };

            cipher.Encrypt(plaintext, new Key <int>(3));
        }
Beispiel #2
0
        public void EncryptWrongTextTest()
        {
            const string plaintext = "aa,cabc";
            var          cipher    = new CaesarCipher(Alphabets.EnglishLower)
            {
                IsStrict = false
            };

            Assert.AreEqual(
                "dd,fdef", cipher.Encrypt(plaintext, new Key <int>(3)));
        }
Beispiel #3
0
        public void EncryptTest()
        {
            var key = new Key <int>(3);

            const string plaintext = "aabcabc";

            string ciphertext = new String(
                plaintext.Select(ch => (char)(ch + key.Value)).ToArray());

            var cipher = new CaesarCipher(Alphabets.EnglishLower);

            Assert.AreEqual(ciphertext, cipher.Encrypt(plaintext, key));
        }
Beispiel #4
0
        public void AbsorbtionTest()
        {
            var encryptionKey = new Key <int>(3);
            var decryptionKey = KeyGenerator.GetCaesarDecryptionKey(encryptionKey);

            const string plaintext = "aabcabc";

            var cipher = new CaesarCipher(Alphabets.English);

            string ciphertext = cipher.Encrypt(plaintext, encryptionKey);

            Assert.AreEqual(plaintext, cipher.Decrypt(ciphertext, decryptionKey));
        }
Beispiel #5
0
        public void DecryptTest()
        {
            var encryptionKey = new Key <int>(3);
            var decryptionKey = KeyGenerator.GetCaesarDecryptionKey(
                encryptionKey);

            const string plaintext = "aabcabc";

            string ciphertext = new String(
                plaintext.Select(
                    ch => (char)(ch + encryptionKey.Value)).ToArray());

            var cipher = new CaesarCipher(Alphabets.EnglishLower);

            Assert.AreEqual(
                plaintext, cipher.Decrypt(ciphertext, decryptionKey));
        }
 public void CreateWithNullTest()
 {
     var cipher = new CaesarCipher(null);
 }
        public void CreateTest()
        {
            var cipher = new CaesarCipher(Alphabets.English);

            Assert.AreEqual(Alphabets.English, cipher.Alphabet);
        }
Beispiel #8
0
        public void EncryptWithNullTest()
        {
            var cipher = new CaesarCipher(Alphabets.English);

            cipher.Encrypt("aaa", null);
        }
Beispiel #9
0
        public void EncryptNullTest()
        {
            var cipher = new CaesarCipher(Alphabets.English);

            cipher.Encrypt(null, new Key <int>(3));
        }