示例#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));
        }
示例#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)));
        }
示例#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));
        }
示例#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));
        }
示例#5
0
        public void EncryptWithNullTest()
        {
            var cipher = new CaesarCipher(Alphabets.English);

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

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