public static void ShowAnswers() { Console.WriteLine("Showing Vigenere decryption:"); var currentKey = FileHelper.GetKey("VigenereFirstTask.txt"); var currentMessage = FileHelper.GetMessage("VigenereFirstTask.txt"); Console.WriteLine($"Vigenere first decryption. Key = {currentKey}:"); foreach (var decryption in VigenereCipher.Decrypt(currentMessage, currentKey)) { Console.Write(decryption); } currentMessage = FileHelper.GetMessage("VigenereSecondTask.txt"); Console.WriteLine($"{Environment.NewLine}Vigenere second decryption."); foreach (var decryption in VigenereCipher.DecryptFromFrequencies(currentMessage, 7)) { Console.WriteLine(decryption); } currentMessage = FileHelper.GetMessage("VigenereThirdTask.txt"); Console.WriteLine($"Vigenere third decryption."); foreach (var decryption in VigenereCipher.DecryptFromFrequencies(currentMessage, 6)) { Console.WriteLine(decryption); } currentKey = FileHelper.GetKey("VigenereFouthTask.txt"); currentMessage = FileHelper.GetMessage("VigenereFouthTask.txt"); Console.WriteLine($"Vigenere fourth decryption. Key = {currentKey}:"); foreach (var decryption in VigenereAutoKeyCipher.Decrypt(currentMessage, currentKey)) { Console.WriteLine(decryption); } }
private void button1_Click(object sender, EventArgs e) { // Eğer textbox'lar boş değilse program başlıyor if (txtAnahtarKelime.Text != "" && txtYaziSifre.Text != "") { // Yazdığım sınıftan bir nesne oluşturuyorum. VigenereCipher vigenere = new VigenereCipher(txtAnahtarKelime.Text, txtYaziSifre.Text); // Anahtar kelimenin sadece İngilizce karakterler içerip içermediğine bakıyorum. Sorun varsa uyarı mesajı yazdırıyorum if (vigenere.AnahtarKelimeAlfabetikMi()) { // Nesnenin "Sifrele" metodunu kullanarak yazıyı şifreliyorum ve textbox'a yazdırıyorum. txtDesifreEdilenYazi.Text = vigenere.DesifreEt(); } else { MessageBox.Show("Lütfen anahtar kelimeye İngilizce karakter dışında birşey girmeyiniz."); } } // Eğer kutular boşsa ekrana uyarı mesajı yazdırıyorum else { MessageBox.Show("Lütfen kutuları boş bırakmayınız."); } }
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 cipherText0 = "UIF RVJDL CSPXO GPY KVNQT PWFS 13 MBAZ EPHT."; // 1 Console.WriteLine("Test Cipher Text: " + CaesarCipher.decrypt(cipherText0, 1)); //string cipherText1 = "KVXUAOGRRDRBGFTPDVWRMCDWTELUAWXILKNZGVXTYHPEMQVHVETIABPSMVHXYIGFMBNLLPOPDAENTAGNLRETMSTIABPHXVAEMSICSLKOGCTXNYTPDXNOJWEGVLRCNWER"; //string cipherText1 = "ASTZHSSJNSBZFPSSJESNTBPZHNLREYUWCFWYUAXSJEGSTHDDCIPCBEVADINCCQYREYUBLFIDVWJOJOKDPOPQFKXHDPTWCASTZHMSOZZZLBZEVASSJDONPHKWRPSOPEVA"; string cipherText1 = "FWURLERNWEAIFLXFNTIEUVCHDIGXMHIEIIOGFUGTEWRNWZTLVEFJTARTMYEREOPFPIFSXVAVYOMYEKFNXMEKPPKFPHJAEJNHNBTCLLVLHHUXECXRLEFWLYIFKOVFNMIO"; Console.WriteLine("CipherText: " + cipherText1); Console.WriteLine("\nPlain Text: " + VigenereCipher.decrypt(cipherText1, 3)); 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); }
static void Main(string[] args) { //table contains chars from range 32 - 126 VigenereCipher cipher = new VigenereCipher(32, 126); //print table Console.WriteLine(cipher.tableToString(" ")); //encrypting and decrypting word "MICHIGAN" using key string key = ".F#1s!"; string encrypt = cipher.encrypt("MICHIGAN", key); string decrypt = cipher.decrypt(encrypt, key); //print results Console.WriteLine(encrypt); Console.WriteLine(decrypt); Console.ReadKey(); }