コード例 #1
0
ファイル: Program.cs プロジェクト: viliusgec/TU_homework
        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");
        }