Пример #1
0
        /*********************************************/
        /*********** One big word attack *************/
        /*********************************************/
        private List<string> BigWordAttack(string ciphertext, Storage.Languages language)
        {
            ciphertext = Analyse.NormalizeText(ciphertext, Analyse.TextTypes.WithoutSpacesLower);
            var keyLengths = GetKeyLengths(ciphertext);
            LangCharacteristic lang = Storage.GetLangChar(language);
            List<string> possKeys = new List<string>();

            foreach (int keyLength in keyLengths)
            {

                string[] columns = GetDecryptColumns(ciphertext, keyLength);
                string[] rows = GetRows(columns);

                DictionaryAttack attack = new DictionaryAttack();
                string[] keys = attack.GetKeys(rows, lang.TopWords);
                string[] orderedKeys = OrderKeys(keys, ciphertext, lang);
                if (orderedKeys.Length > 0)
                    possKeys.Add(orderedKeys[0]);
            }

            if (possKeys.Count > 0)
            {
                string[] finalKeys = OrderKeys(possKeys.ToArray(), ciphertext, lang);
                return finalKeys.ToList();
            }

            throw new Exceptions.MatchNotFound();
        }