예제 #1
0
        public void UnitCaesarDecipher()
        {
            string text = "DEFGHIJKLMNOPQRSTUVWXYZABC";
            string cipher = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int shift = 3;

            CaesarCipher caesarCipher = new CaesarCipher(OldPlain, shift);

            Assert.That(cipher == caesarCipher.Decrypt(text));
        }
예제 #2
0
        public void UnitCaesarCipherDecipher()
        {
            string text = "Salut, je suis un message COOL!!!";
            int shift = 8;

            CaesarCipher caesarCipher = new CaesarCipher(shift);

            string crypt = caesarCipher.Encrypt(text);

            System.Console.WriteLine(text + " != " + crypt);
            Assert.That(text != crypt);

            crypt = caesarCipher.Decrypt(crypt);

            System.Console.WriteLine(text + " == " + crypt);
            Assert.That(text == crypt);
        }
예제 #3
0
        public void UnitRandomCaesarCipher()
        {
            Random random = new Random(ToolCipher.RandomSeed);
            for (int i = 0; i < 500; i++)
            {
                string text = ToolCipher.GenerateText(ToolCipher.AllChar, 500);
                int shift = random.Next(4, CaesarCipher.DEFAULT_PLAIN.Length - 1);
                System.Console.Out.WriteLine(shift);

                CaesarCipher caesarCipher = new CaesarCipher(shift);

                string textEncrypt = caesarCipher.Encrypt(text);
                System.Console.Out.WriteLine(text);
                System.Console.Out.WriteLine(textEncrypt);
                Assert.That(text != textEncrypt);

                string textDecrypt = caesarCipher.Decrypt(textEncrypt);

                System.Console.Out.WriteLine(text);
                System.Console.Out.WriteLine(textDecrypt);
                Assert.That(text == textDecrypt);
            }
        }