예제 #1
0
        public static string AnalyzeNoKey(string inStr)
        {
            var decryptList = new DecryptObjList();

            // Try the Caesar Ciphers
            for (var i = 1; i < 26; i++)
            {
                var decryptStr = CaesarTools.RotNDecrypt(i, inStr);
                var count      = NumberOfLibraryMatches(decryptStr);
                if (count >= PositiveMatchCount)
                {
                    var keyStr = "ROT-" + i;
                    DecryptObjList.AddObj(new DecryptObj(keyStr, count, decryptStr));
                }
            }

            // Now try the Rail Fence Ciphers
            for (var i = 3; i < 7; i++)
            {
                var decryptStr = RailFence.RailFenceDecrypt(inStr, i);
                var count      = NumberOfLibraryMatches(decryptStr);
                if (count >= PositiveMatchCount)
                {
                    var keyStr = "Rail Fence-" + i;
                    DecryptObjList.AddObj(new DecryptObj(keyStr, count, decryptStr));
                }
            }

            return(decryptList.BuildList());
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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;
            }
        }