static void Main(string[] args) { var cipher = new VigenereCipher(); string language; while (true) { Console.Write("Enter the required language (\"RU\" or \"EN\"): "); var answer = Console.ReadLine(); if (answer == "RU") { language = "RU"; break; } else if (answer == "EN") { language = "EN"; break; } } Console.Write("Enter text: "); var message = Console.ReadLine().ToUpper(); Console.Write("Enter key: "); var key = Console.ReadLine().ToUpper(); var encryptedText = cipher.Encrypt(language, message, key); Console.WriteLine("Encrypted message: {0}", encryptedText); Console.WriteLine("Decrypted message: {0}", cipher.Decrypt(language, encryptedText, key)); Console.ReadLine(); }
static void Main(string[] args) { string alphabet = "abcdefghijklmnopqrstuvwxyz"; VigenereCipher cipher = new VigenereCipher(alphabet); string key = "battista"; string plainText = "this is a test message."; string cipherText = cipher.Encrypt(plainText, key); string decipheredText = cipher.Decrypt(cipherText, key); Console.WriteLine($"Plaintext: {plainText}"); Console.WriteLine($"Key: {key}"); Console.WriteLine($"Lengthen Key: {cipher.LengthenKey(key, plainText)}"); Console.WriteLine($"Ciphertext: {cipherText}"); Console.WriteLine($"Deciphered: {decipheredText}"); }
//User gives message and key and the message will be encrypted public static void Encrypt() { Console.WriteLine("Your Message: "); string message = Console.ReadLine(); Console.WriteLine("Your Key: "); string key = Console.ReadLine(); string encryption = VigenereCipher.Encrypt(message, key); for (int i = 0; i <= 100; i++) { Console.Write($"\rEncrypting: {i}% "); Thread.Sleep(25); } Thread.Sleep(1000); Console.WriteLine("\rEncrypted message: " + encryption); }