Интернет магазин китайских планшетных компьютеров



Компьютеры - Метод Касиски - Пример реализации на языке Java

23 января 2011


Оглавление:
1. Метод Касиски
2. Пример
3. Пример реализации на языке Java



public void kasiskiAttack {
                Vector trigramList = new Vector;
                String input = strip );
                String trigram;
 
                // need at least 3 chars of cyphertext
                if < 3 )
                        return;
 
                // go through all the trigrams in the cyphertext
                for-2; ++i ) {
                        trigram = input.substring;
 
                        // if the trigram occurs more than once, put it in a list
                        if != -1 ) {
                                if == -1 )
                                        trigramList.addElement;                                    
                        }
                }
 
                // go through the list of repeated trigrams and do distance calculations, etc
                for; ++i ) {
                        trigram = trigramList.elementAt;
                        int count = 0;
 
                        // make an array of the positions of this trigram
                        int posArray = new int;
                        int index = input.indexOf;
                        while {
                                posArray = index;
                                index = input.indexOf;
                        }
 
                        // output the number of times the trigram occurs, and where
                        output.append;
                        for
                                output.append + posArray );
                        output.append: " );
 
                        // now output the distance apart the trigrams occurred
                        for {
                                for
                                        output.append +  );
                        }
                        output.append;
                }
                output.append;
   }




Просмотров: 4688


<<< Машина Лоренца
Модель угрозы Долева-Яо >>>