Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter a password to use:");
            string password = Console.ReadLine();

            Console.WriteLine("Please enter a string to encrypt:");
            string plaintext = Console.ReadLine();

            Console.WriteLine("");

            Console.WriteLine("Your encrypted string is:");
            string encryptedstring = StringCipher.Encrypt(plaintext, password);

            Console.WriteLine(encryptedstring);
            Console.WriteLine("");

            Console.WriteLine("Your decrypted string is:");
            string decryptedstring = StringCipher.Decrypt(encryptedstring, password);

            Console.WriteLine(decryptedstring);
            Console.WriteLine("");

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
Exemple #2
0
        static void Main()
        {
            while (true)
            {
                Console.WriteLine("Encrypt (E) or Decrypt (D)?");
                string EncOrDec = Console.ReadLine().ToUpper();
                switch (EncOrDec)
                {
                case "E":

                    string EncryptionKey;
                    string plaintext;
                    Console.WriteLine("Enter plaintext: ");
                    plaintext = Console.ReadLine();
                    Console.WriteLine("Enter encryption key: ");
                    EncryptionKey = Console.ReadLine();
                    Console.WriteLine("Your encrypted string is:");
                    string encryptedstring = StringCipher.Encrypt(plaintext, EncryptionKey);
                    Console.WriteLine(encryptedstring);
                    Console.WriteLine("");
                    break;

                case "D":

                    string DecryptionKey;
                    string CipherText;
                    Console.WriteLine("Enter Ciphertext: ");
                    CipherText = Console.ReadLine();
                    Console.WriteLine("Enter Decryption key: ");
                    DecryptionKey = Console.ReadLine();
                    Console.WriteLine("Your Decrypted string is:");
                    string decryptedString = StringCipher.Decrypt(CipherText, DecryptionKey);
                    Console.WriteLine(decryptedString);
                    Console.WriteLine("");
                    break;
                }
            }
        }