Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace vigenere
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("1.feladat");
- Console.WriteLine("Adj meg egy szöveget ékezettel, írásjellel!");
- string nyilt = Console.ReadLine();
- nyilt = nyilt.ToUpper();
- Console.WriteLine("eredeti upperelve " + nyilt);
- string elegans = "";
- for (int i = 0; i < nyilt.Length; i++)
- {
- if (nyilt[i] == 'Á') { nyilt = nyilt.Replace(nyilt[i], 'A'); Console.WriteLine("Itt vagyok!" + nyilt); }
- else if (nyilt[i] == 'É') { nyilt = nyilt.Replace(nyilt[i], 'E'); }
- else if (nyilt[i] == 'Í') { nyilt = nyilt.Replace(nyilt[i], 'I'); }
- else if (nyilt[i] == 'Ó' || nyilt[i] == 'Ö' || nyilt[i] == 'Õ') { nyilt = nyilt.Replace(nyilt[i], 'O');}
- else if (nyilt[i] == 'Ú' || nyilt[i] == 'Ü' || nyilt[i] == 'Û') { nyilt = nyilt.Replace(nyilt[i], 'U');}
- else if(nyilt[i] != '!' && nyilt[i] != '.' && nyilt[i] != '?' && nyilt[i] != ',' && nyilt[i] != ' ' && nyilt[i] != ';') { elegans += nyilt[i];}
- }
- Console.WriteLine(" "+elegans);
- StreamReader sr = new StreamReader("vtabla.dat");
- char[,] betuk = new char[26, 26];
- string sorr;
- for (int i = 0; i < 26; i++)
- {
- sorr = sr.ReadLine();
- for (int j = 0; j < 26; j++)
- {
- betuk[i, j] = sorr[j];
- }
- }
- for (int i = 0; i < 26; i++)
- {
- for (int j = 0; j < 26; j++)
- {
- Console.Write(betuk[i, j]);
- }
- Console.WriteLine();
- }
- sr.Close();
- Console.WriteLine(" Adj meg egy kulcsszót!");
- string er_kulcs = Console.ReadLine();
- er_kulcs.ToUpper();
- int hossza_kulcsnak = er_kulcs.Count();
- int sor_hossza = elegans.Count();
- string autozok = "";
- int hanyszor = sor_hossza / hossza_kulcsnak;
- for (int i = 0; i < hanyszor; i++)
- {
- autozok += er_kulcs;
- }
- Console.WriteLine(autozok);
- int sorindex = 0;
- int oszlopindex = 0;
- string kodolt = "";
- for (int j = 0; j < 26; j++)
- {
- for (int i = 0; i < 26; i++)
- {
- if (elegans[j] == betuk[i, 0]) { sorindex = i; }
- if (autozok[j] == betuk[0, i]){oszlopindex = i;}
- }
- kodolt += betuk[sorindex, oszlopindex];
- }
- // FileStream fs = new FileStream("kodolt.txt", FileMode.Create, Encoding.Default);
- StreamWriter sw = new StreamWriter("kodolt.txt");
- sw.WriteLine(kodolt);
- Console.WriteLine(kodolt);
- sw.Close();
- // fs.Close();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement