using System; using System.Windows; using System.Windows.Forms; namespace ROTFinder2._0 { class Program { static void Main() { int Menu_1 = 1; bool Scn1 = true; // Loop back in order to clear the screen and redraw the text, pretending we have graphics while (Scn1 == true) { // Keep Menu_1 in the 1 or 2 range switch (Menu_1) { case 0: Menu_1 = 2; continue; case 3: Menu_1 = 1; continue; } // Screen clearing will be disabled if it's not possible. if (!Console.IsOutputRedirected) Console.Clear(); Console.WriteLine("Welcome to Zack's All-in-One ROT Tool 2.0"); if (Menu_1 == 1) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("-> A) Write"); Console.ForegroundColor = ConsoleColor.White; } else { Console.WriteLine("A) Write"); } if (Menu_1 == 2) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("-> B) Read"); Console.ForegroundColor = ConsoleColor.White; } else { Console.WriteLine("B) Read"); } ConsoleKeyInfo Lastkey = Console.ReadKey(); string LastKeyPressed = Convert.ToString(Lastkey.Key); switch (LastKeyPressed) { case "DownArrow": { Menu_1 += 1; continue; } case "UpArrow": { Menu_1 -= 1; continue; } case "Enter": { if (Menu_1 == 1) { Scn1 = false; Create(); break; } else { Scn1 = false; Read(); break; } } } } Console.ReadLine(); static void Create() { if (!Console.IsOutputRedirected) Console.Clear(); Console.WriteLine("====== CODE CREATOR ======"); Console.Write("Text goes here: "); string Start = Console.ReadLine(); Console.WriteLine("ROT Number Here"); Console.WriteLine("The ROT Number is the amount of characters shifted over, with ROT 5 'a' becomes 'f'"); int rot = Convert.ToInt32(Console.ReadLine()); string newtext = ROTgen(Start, rot); Console.WriteLine(newtext); Console.Write("Press any key to continue"); Console.ReadKey(); Main(); } static void Read() { string Output = ""; if (!Console.IsOutputRedirected) Console.Clear(); Console.WriteLine("====== CODE READER ======"); Console.Write("Text goes here: "); string Start = Console.ReadLine(); for (int z = 0; z < 26; z++) { Output = ROTgen(Start, z); Console.WriteLine(Output); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Main(); } static string ROTgen(string Input, int rot) { string CurrentChar = "a"; // The alphabet is doubled for rotations that go past Z string alphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; string newtext = ""; int CurrentIndex = 0; // Converting the input to lowercase to make the chart simpler Input = Input.ToLower(); // For each character in the string for (int i = 0; i < Input.Length; i++) { CurrentChar = Input.Substring(i, 1); // If the current character is a letter, do the swap, if it's a symbol, leave it the same. if (alphabet.Contains(CurrentChar)) { /*Get the index of the current letter in the chart, add the ROT value, then find the character that corrosponds to the new index */ CurrentIndex = Convert.ToInt32(alphabet.IndexOf(CurrentChar, 0)); CurrentIndex = CurrentIndex + rot; newtext += alphabet.Substring(CurrentIndex, 1); } else { newtext += CurrentChar; } } return newtext; } } } }