コード例 #1
0
        static void Main(string[] args)
        {
            var key  = GetKey();
            var text = GetText();

            Console.WriteLine("---Encryption---");

            var encryptedText = CaesarCipher.Encrypt(text, key);

            Console.WriteLine(encryptedText);

            Console.WriteLine("---Decryption---");

            var decryptedText = CaesarCipher.Decrypt(encryptedText, key);

            Console.WriteLine(decryptedText);

            Console.WriteLine("---Hacking---");

            var attempts = CaesarCipher.TryHack(encryptedText);
            var output   = string.Join("\n", attempts);

            Console.WriteLine(output);

            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // User input for Shift variable
            CaesarCipher cc    = new CaesarCipher();
            int          shift = shift_input();
            string       text  = text_input();

            string encrypted_text = cc.encrypt(text, shift);
            string decrypted_text = cc.decrypt(encrypted_text, shift);

            Console.WriteLine($"Encrypted text: {encrypted_text}");
            Console.WriteLine($"Decrypted text: {decrypted_text}");
        }