public static string AnalyzeKeyGuess(string inStr, string keyGuess) { var outStr = new StringBuilder(); var count = 0; var decryptList = new DecryptObjList(); // Try Vigenere var decryptStr = Vigenere.VigenereDecode(inStr, keyGuess); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj("Vigenere", count, decryptStr)); } // Try Fractionated Morse decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyGuess); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj("Fractionated Morse", count, decryptStr)); } // Try Keyword decryptStr = Miscellaneous.KeywordCipherDecode(inStr, keyGuess, ""); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj("Keyword", count, decryptStr)); } // Try Playfair decryptStr = Playfair.PlayfairDecrypt(inStr, keyGuess); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj("Playfair", count, decryptStr)); } return(decryptList.BuildList()); }
public static string FracMorseKeyBruteForce(string inStr) { var outStr = new StringBuilder(); var keyStr = new StringBuilder(); var count = 0; var decryptList = new DecryptObjList(); // 1 letter keys for (var i1 = 0; i1 < 26; i1++) { keyStr.Length = 0; keyStr.Append((char)('a' + i1)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } // 2 letter keys for (var i1 = 0; i1 < 26; i1++) { for (var i2 = 0; i2 < 26; i2++) { keyStr.Length = 0; keyStr.AppendFormat("{0}{1}", (char)('a' + i1), (char)('a' + i2)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } } // 3 letter keys for (var i1 = 0; i1 < 26; i1++) { for (var i2 = 0; i2 < 26; i2++) { for (var i3 = 3; i3 < 26; i3++) { keyStr.Length = 0; keyStr.AppendFormat("{0}{1}{2}", (char)('a' + i1), (char)('a' + i2), (char)('a' + i3)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } } } // 4 letter keys for (var i1 = 0; i1 < 26; i1++) { for (var i2 = 0; i2 < 26; i2++) { for (var i3 = 0; i3 < 26; i3++) { for (var i4 = 0; i4 < 26; i4++) { keyStr.Length = 0; keyStr.AppendFormat("{0}{1}{2}{3}", (char)('a' + i1), (char)('a' + i2), (char)('a' + i3), (char)('a' + i4)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } } } } if (FullRun) { // 5 letter keys for (var i1 = 0; i1 < 26; i1++) { for (var i2 = 0; i2 < 26; i2++) { for (var i3 = 0; i3 < 26; i3++) { for (var i4 = 0; i4 < 26; i4++) { for (var i5 = 0; i5 < 26; i5++) { keyStr.Length = 0; keyStr.AppendFormat("{0}{1}{2}{3}{4}", (char)('a' + i1), (char)('a' + i2), (char)('a' + i3), (char)('a' + i4), (char)('a' + i5)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } } } } } // 6 letter keys - 5 letters and x for (var i1 = 0; i1 < 26; i1++) { for (var i2 = 0; i2 < 26; i2++) { for (var i3 = 0; i3 < 26; i3++) { for (var i4 = 0; i4 < 26; i4++) { for (var i5 = 0; i5 < 26; i5++) { keyStr.Length = 0; keyStr.AppendFormat("{0}{1}{2}{3}{4}x", (char)('a' + i1), (char)('a' + i2), (char)('a' + i3), (char)('a' + i4), (char)('a' + i5)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } } } } } // 7 letter keys - 5 letters and xx for (var i1 = 0; i1 < 26; i1++) { for (var i2 = 0; i2 < 26; i2++) { for (var i3 = 0; i3 < 26; i3++) { for (var i4 = 0; i4 < 26; i4++) { for (var i5 = 0; i5 < 26; i5++) { keyStr.Length = 0; keyStr.AppendFormat("{0}{1}{2}{3}{4}xx", (char)('a' + i1), (char)('a' + i2), (char)('a' + i3), (char)('a' + i4), (char)('a' + i5)); var decryptStr = Morse.FracMorseCodeDecrypt(inStr, keyStr.ToString()); count = NumberOfLibraryMatches(decryptStr); if (count >= PositiveMatchCount) { DecryptObjList.AddObj(new DecryptObj(keyStr.ToString(), count, decryptStr)); } } } } } } } return(decryptList.BuildList()); }
protected void Button2_Click(object sender, EventArgs e) { int numRows; switch (DropDownList3.Text) { case "Caesar Tools": switch (DropDownList4.Text) { case "ROT-13": TextBox2.Text = CaesarTools.RotNEncrypt(13, TextBox1.Text); break; case "ROT-1": TextBox2.Text = CaesarTools.RotNEncrypt(1, TextBox1.Text); break; case "ROT-2": TextBox2.Text = CaesarTools.RotNEncrypt(2, TextBox1.Text); break; case "ROT-3": TextBox2.Text = CaesarTools.RotNEncrypt(3, TextBox1.Text); break; case "ROT-4": TextBox2.Text = CaesarTools.RotNEncrypt(4, TextBox1.Text); break; case "ROT-5": TextBox2.Text = CaesarTools.RotNEncrypt(5, TextBox1.Text); break; case "ROT-6": TextBox2.Text = CaesarTools.RotNEncrypt(6, TextBox1.Text); break; case "ROT-7": TextBox2.Text = CaesarTools.RotNEncrypt(7, TextBox1.Text); break; case "ROT-8": TextBox2.Text = CaesarTools.RotNEncrypt(8, TextBox1.Text); break; case "ROT-9": TextBox2.Text = CaesarTools.RotNEncrypt(9, TextBox1.Text); break; case "ROT-10": TextBox2.Text = CaesarTools.RotNEncrypt(10, TextBox1.Text); break; case "ROT-11": TextBox2.Text = CaesarTools.RotNEncrypt(11, TextBox1.Text); break; case "ROT-12": TextBox2.Text = CaesarTools.RotNEncrypt(12, TextBox1.Text); break; case "ROT-14": TextBox2.Text = CaesarTools.RotNEncrypt(14, TextBox1.Text); break; case "ROT-15": TextBox2.Text = CaesarTools.RotNEncrypt(15, TextBox1.Text); break; case "ROT-16": TextBox2.Text = CaesarTools.RotNEncrypt(16, TextBox1.Text); break; case "ROT-17": TextBox2.Text = CaesarTools.RotNEncrypt(17, TextBox1.Text); break; case "ROT-18": TextBox2.Text = CaesarTools.RotNEncrypt(18, TextBox1.Text); break; case "ROT-19": TextBox2.Text = CaesarTools.RotNEncrypt(19, TextBox1.Text); break; case "ROT-20": TextBox2.Text = CaesarTools.RotNEncrypt(20, TextBox1.Text); break; case "ROT-21": TextBox2.Text = CaesarTools.RotNEncrypt(21, TextBox1.Text); break; case "ROT-22": TextBox2.Text = CaesarTools.RotNEncrypt(22, TextBox1.Text); break; case "ROT-23": TextBox2.Text = CaesarTools.RotNEncrypt(23, TextBox1.Text); break; case "ROT-24": TextBox2.Text = CaesarTools.RotNEncrypt(24, TextBox1.Text); break; case "ROT-25": TextBox2.Text = CaesarTools.RotNEncrypt(25, TextBox1.Text); break; case "Caesar Bruteforce": TextBox2.Text = CaesarTools.CaesarBruteforce(TextBox1.Text); break; default: TextBox2.Text = "Unknown Caesar Tools option"; break; } break; case "Vigenere Tools": switch (DropDownList4.Text) { case "Vigenere Cipher Encoder": TextBox2.Text = Vigenere.VigenereEncode(TextBox1.Text, TextBox3.Text); break; default: TextBox2.Text = "Unknown Vigenere Tools option"; break; } break; case "Morse Code Tools": switch (DropDownList4.Text) { case "Morse Code Encrypt": TextBox2.Text = Morse.MorseCodeEncrypt(TextBox1.Text); break; case "Fractionated Morse Encrypt": TextBox2.Text = Morse.FracMorseCodeEncrypt(TextBox1.Text, TextBox3.Text); break; default: TextBox2.Text = "Unknown Morse Code option"; break; } break; case "Bacon Ciphers": switch (DropDownList4.Text) { case "Baconian Cipher": switch (DropDownList6.Text) { case "24 letter alphabet": TextBox2.Text = BaconianTools.BaconianEncode(TextBox1.Text, false); break; case "26 letter alphabet": TextBox2.Text = BaconianTools.BaconianEncode(TextBox1.Text, true); break; default: break; } break; case "Bacon's Biliteral - lower case == A": switch (DropDownList6.Text) { case "24 letter alphabet": TextBox2.Text = BaconianTools.BaconBiliteralEncode(TextBox1.Text, false); break; case "26 letter alphabet": TextBox2.Text = BaconianTools.BaconBiliteralEncode(TextBox1.Text, true); break; default: break; } break; default: TextBox2.Text = "Unknown Bacon Cipher option"; break; } break; case "Miscellaneous Ciphers": switch (DropDownList4.Text) { case "Keyword Cipher": TextBox2.Text = Miscellaneous.KeywordCipherEncode(TextBox1.Text, TextBox3.Text, TextBox6.Text); break; case "Playfair Cipher": TextBox2.Text = Playfair.PlayfairEncrypt(TextBox1.Text, TextBox3.Text); break; case "One Time Pad": TextBox2.Text = OneTimePadTools.OneTimePadEncrypt(TextBox1.Text, TextBox3.Text); break; case "Rail Fence Cipher": numRows = DropDownList6.Text[0] - '0'; TextBox2.Text = RailFence.RailFenceEncrypt(TextBox1.Text, numRows); break; default: TextBox2.Text = "Unknown Miscellaneous Code option"; break; } break; default: TextBox2.Text = "Unknown option."; break; } }
protected void Button1_Click(object sender, EventArgs e) { int numRows; switch (DropDownList1.Text) { case "Caesar Tools": switch (DropDownList2.Text) { case "ROT-13": TextBox2.Text = CaesarTools.RotNDecrypt(13, TextBox1.Text); break; case "ROT-1": TextBox2.Text = CaesarTools.RotNDecrypt(1, TextBox1.Text); break; case "ROT-2": TextBox2.Text = CaesarTools.RotNDecrypt(2, TextBox1.Text); break; case "ROT-3": TextBox2.Text = CaesarTools.RotNDecrypt(3, TextBox1.Text); break; case "ROT-4": TextBox2.Text = CaesarTools.RotNDecrypt(4, TextBox1.Text); break; case "ROT-5": TextBox2.Text = CaesarTools.RotNDecrypt(5, TextBox1.Text); break; case "ROT-6": TextBox2.Text = CaesarTools.RotNDecrypt(6, TextBox1.Text); break; case "ROT-7": TextBox2.Text = CaesarTools.RotNDecrypt(7, TextBox1.Text); break; case "ROT-8": TextBox2.Text = CaesarTools.RotNDecrypt(8, TextBox1.Text); break; case "ROT-9": TextBox2.Text = CaesarTools.RotNDecrypt(9, TextBox1.Text); break; case "ROT-10": TextBox2.Text = CaesarTools.RotNDecrypt(10, TextBox1.Text); break; case "ROT-11": TextBox2.Text = CaesarTools.RotNDecrypt(11, TextBox1.Text); break; case "ROT-12": TextBox2.Text = CaesarTools.RotNDecrypt(12, TextBox1.Text); break; case "ROT-14": TextBox2.Text = CaesarTools.RotNDecrypt(14, TextBox1.Text); break; case "ROT-15": TextBox2.Text = CaesarTools.RotNDecrypt(15, TextBox1.Text); break; case "ROT-16": TextBox2.Text = CaesarTools.RotNDecrypt(16, TextBox1.Text); break; case "ROT-17": TextBox2.Text = CaesarTools.RotNDecrypt(17, TextBox1.Text); break; case "ROT-18": TextBox2.Text = CaesarTools.RotNDecrypt(18, TextBox1.Text); break; case "ROT-19": TextBox2.Text = CaesarTools.RotNDecrypt(19, TextBox1.Text); break; case "ROT-20": TextBox2.Text = CaesarTools.RotNDecrypt(20, TextBox1.Text); break; case "ROT-21": TextBox2.Text = CaesarTools.RotNDecrypt(21, TextBox1.Text); break; case "ROT-22": TextBox2.Text = CaesarTools.RotNDecrypt(22, TextBox1.Text); break; case "ROT-23": TextBox2.Text = CaesarTools.RotNDecrypt(23, TextBox1.Text); break; case "ROT-24": TextBox2.Text = CaesarTools.RotNDecrypt(24, TextBox1.Text); break; case "ROT-25": TextBox2.Text = CaesarTools.RotNDecrypt(25, TextBox1.Text); break; case "Caesar Bruteforce": TextBox2.Text = CaesarTools.CaesarBruteforce(TextBox1.Text); break; default: TextBox2.Text = "Unknown Caesar Tools option"; break; } break; case "ASCII Tools": switch (DropDownList2.Text) { case "Decimal to ASCII": TextBox2.Text = AsciiTools.DecimalToAscii(TextBox1.Text); break; case "Hex to ASCII": TextBox2.Text = AsciiTools.HexToAscii(TextBox1.Text); break; case "Binary to ASCII": TextBox2.Text = AsciiTools.BinaryToAscii(TextBox1.Text); break; case "ASCII to Decimal": TextBox2.Text = AsciiTools.AsciiToDecimal(TextBox1.Text); break; case "ASCII to Hex": TextBox2.Text = AsciiTools.AsciiToHex(TextBox1.Text); break; case "ASCII to Binary": TextBox2.Text = AsciiTools.AsciiToBinary(TextBox1.Text); break; case "Binary to Decimal": TextBox2.Text = AsciiTools.BinaryToDecimal(TextBox1.Text); break; case "Binary to Hex": TextBox2.Text = AsciiTools.BinaryToHex(TextBox1.Text); break; case "Number to Letter (a = 1)": TextBox2.Text = AsciiTools.NumberToLetter(TextBox1.Text); break; case "Index into String": TextBox2.Text = AsciiTools.IndexIntoString(TextBox1.Text, TextBox3.Text); break; default: TextBox2.Text = "Unknown ASCII option"; break; } break; case "Vigenere Tools": switch (DropDownList2.Text) { case "Vigenere Cipher Decoder": TextBox2.Text = Vigenere.VigenereDecode(TextBox1.Text, TextBox3.Text); break; case "Vigenere Key Guesser": TextBox3.Text = Vigenere.VigenereKeyGuesser(TextBox1.Text, TextBox2.Text); break; default: TextBox2.Text = "Unknown Vigenere option"; break; } break; case "Morse Code Tools": switch (DropDownList2.Text) { case "Morse Code Decrypt": TextBox2.Text = Morse.MorseCodeDecrypt(TextBox1.Text); break; case "Fractionated Morse Decrypt": TextBox2.Text = Morse.FracMorseCodeDecrypt(TextBox1.Text, TextBox3.Text); break; default: TextBox2.Text = "Unknown Morse Code option"; break; } break; case "Bacon Ciphers": switch (DropDownList2.Text) { case "Baconian Cipher": switch (DropDownList5.Text) { case "24 letter alphabet": TextBox2.Text = BaconianTools.BaconianDecode(TextBox1.Text, false); break; case "26 letter alphabet": TextBox2.Text = BaconianTools.BaconianDecode(TextBox1.Text, true); break; default: break; } break; case "Bacon's Biliteral - lower case == A": switch (DropDownList5.Text) { case "24 letter alphabet": TextBox2.Text = BaconianTools.BaconBiliteralDecode(TextBox1.Text, false); break; case "26 letter alphabet": TextBox2.Text = BaconianTools.BaconBiliteralDecode(TextBox1.Text, true); break; default: break; } break; default: TextBox2.Text = "Unknown Bacon Cipher option"; break; } break; case "Miscellaneous Ciphers": switch (DropDownList2.Text) { case "Keyword Cipher": TextBox2.Text = Miscellaneous.KeywordCipherDecode(TextBox1.Text, TextBox3.Text, TextBox6.Text); break; case "Playfair Cipher": TextBox2.Text = Playfair.PlayfairDecrypt(TextBox1.Text, TextBox3.Text); break; case "Playfair Key Square": TextBox2.Text = Playfair.PrintKeyTable(TextBox3.Text); break; case "One Time Pad": TextBox2.Text = OneTimePadTools.OneTimePadDecrypt(TextBox1.Text, TextBox3.Text); break; case "One Time Pad Key Guesser": TextBox2.Text = OneTimePadTools.OneTimePadKeyGuesser(TextBox1.Text, TextBox3.Text); break; case "Rail Fence Cipher": numRows = DropDownList5.Text[0] - '0'; TextBox2.Text = RailFence.RailFenceDecrypt(TextBox1.Text, numRows); break; default: TextBox2.Text = "Unknown Miscellaneous Code option"; break; } break; case "Tools": switch (DropDownList2.Text) { case "Reverse String": TextBox2.Text = Utilities.ReverseString(TextBox1.Text); break; case "Text Offset": TextBox2.Text = Utilities.ComputeTextOffset(TextBox1.Text, TextBox4.Text, TextBox5.Text); break; case "Show just CAPS": TextBox2.Text = Utilities.OnlyCaps(TextBox1.Text); break; case "Show just lowercase": TextBox2.Text = Utilities.OnlyLower(TextBox1.Text); break; case "Convert to CAPS": TextBox2.Text = Utilities.ToCaps(TextBox1.Text); break; case "Convert to lowercase": TextBox2.Text = Utilities.ToLower(TextBox1.Text); break; case "Character Count": var outStr = new StringBuilder(); outStr.AppendFormat("{0} characters", TextBox1.Text.Length); TextBox2.Text = outStr.ToString(); break; case "Remove Spaces": TextBox2.Text = Utilities.RemoveSpaces(TextBox1.Text); break; case "Remove All But Letters": TextBox2.Text = Utilities.RemoveAllButLetters(TextBox1.Text); break; case "Sum of Letters": TextBox2.Text = Utilities.SumOfLetters(TextBox1.Text); break; case "Test Routine": TextBox2.Text = Utilities.BuildCipherAlphabetFromKey(TextBox3.Text, TextBox6.Text); break; default: TextBox2.Text = "Unknown option"; break; } break; case "Analyze Code": switch (DropDownList2.Text) { case "Analyze - No Key": TextBox2.Text = Analyze.AnalyzeNoKey(TextBox1.Text); break; case "Analyze - Key Guess": TextBox2.Text = Analyze.AnalyzeKeyGuess(TextBox1.Text, TextBox3.Text); break; case "Vigenere Key Brute Force": TextBox2.Text = Analyze.VigenereKeyBruteForce(TextBox1.Text); break; case "Fractionated Morse Brute Force": TextBox2.Text = Analyze.FracMorseKeyBruteForce(TextBox1.Text); break; case "Keyword (Standard Alphabet) Brute Force": TextBox2.Text = Analyze.FracMorseKeyBruteForce(TextBox1.Text); break; default: TextBox2.Text = "Unknown option"; break; } break; default: TextBox2.Text = "Unknown option"; break; } }