Пример #1
0
        static void Main(string[] args)
        {
            int           shift         = getShift();
            string        text          = getText();
            _CaesarCipher cipher        = new _CaesarCipher();
            string        encryptedText = cipher.encryptText(text, shift);
            string        decryptedText = cipher.decryptText(encryptedText, shift);

            Console.WriteLine($"Encrypted text: {encryptedText}");
            Console.WriteLine($"Decypted text: {decryptedText}");
        }
Пример #2
0
        public void TestMethod1()
        {
            string        text          = "ABC";
            string        encryptedText = "CDE";
            int           shift         = 2;
            _CaesarCipher cipher        = new _CaesarCipher();
            string        encryptedT    = cipher.encryptText(text, shift);

            Assert.AreEqual(encryptedText, encryptedT, "Encryption was unsuccessful");
            string decryptedT = cipher.decryptText(encryptedText, shift);

            Assert.AreEqual(text, decryptedT, "Decryption was unsuccessful");
        }
Пример #3
0
        public void TestMethod3()
        {
            string        text          = "Long sentence. With symbols! And 1 number?";
            string        encryptedText = "Jmle qclrclac. Ugrf qwkzmjq! Ylb 1 lskzcp?";
            int           shift         = -28;
            _CaesarCipher cipher        = new _CaesarCipher();
            string        encryptedT    = cipher.encryptText(text, shift);

            Assert.AreEqual(encryptedText, encryptedT, "Encryption was unsuccessful");
            string decryptedT = cipher.decryptText(encryptedText, shift);

            Assert.AreEqual(text, decryptedT, "Decryption was unsuccessful");
        }
Пример #4
0
        public void TestMethod2()
        {
            string        text          = "Long sentence. With symbols! And 1 number?";
            string        encryptedText = "Nqpi ugpvgpeg. Ykvj uaodqnu! Cpf 1 pwodgt?";
            int           shift         = 28;
            _CaesarCipher cipher        = new _CaesarCipher();
            string        encryptedT    = cipher.encryptText(text, shift);

            Assert.AreEqual(encryptedText, encryptedT, "Encryption was unsuccessful");
            string decryptedT = cipher.decryptText(encryptedText, shift);

            Assert.AreEqual(text, decryptedT, "Decryption was unsuccessful");
        }