hcrypto.analyzer
Class WordBasedAnalyzer

java.lang.Object
  extended by hcrypto.analyzer.CryptoAnalyzer
      extended by hcrypto.analyzer.WordBasedAnalyzer
All Implemented Interfaces:
Analyzer, java.lang.Runnable

public class WordBasedAnalyzer
extends CryptoAnalyzer

Analyzes traditional cryptograms of the sort you find in the newspaper. It assumes the text is a word-delimited cryptogram created using a simple substitution cipher. Credits: The algorithm here is based on the algorithm reported by George W. Hart in To decode short cryptograms, CACM 37(9), Sept. 1994, 102-108. At present this analyzer only works for the alphabet 'a' to 'z'. To compile and run from the TestAnalyzer application: cd ~crypto/hcryptoj/1.4/applications/testanalyzer javac -classpath ../../classes -d ../../classes ../../source/hcrypto/analyzer/NgramAnalyzer.java java -classpath ../../classes:. TestAnalyzer analyzers.NgramAnalyzer ga_paramfiles ngram.cgrams.txt


Field Summary
 
Fields inherited from class hcrypto.analyzer.CryptoAnalyzer
PERMUTATION, PLAYFAIR, RAILFENCE, SIMPLESUB
 
Fields inherited from interface hcrypto.analyzer.Analyzer
DECIPHER_LIMIT
 
Constructor Summary
WordBasedAnalyzer()
           
WordBasedAnalyzer(GaParameters params, AnalyzerFrame f)
          WordBasedAnalyzer() -- this constructor is given an object containing parameter settings
 
Method Summary
 void doAnalysis()
          This method performs an analysis of the text.
 java.lang.String getReport()
          This method is part of the Analyzer interface.
 void init()
          This method is called by setup().
 void run()
          This method is part of the Analyzer interface.
 void setup(java.lang.String text)
          This method initializes the Analyzer.
 java.lang.String toString()
          This method returns the report generated by the analysis.
 
Methods inherited from class hcrypto.analyzer.CryptoAnalyzer
prettyPrint, setup, stopThread, threadIsStopped
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WordBasedAnalyzer

public WordBasedAnalyzer(GaParameters params,
                         AnalyzerFrame f)
WordBasedAnalyzer() -- this constructor is given an object containing parameter settings

Parameters:
params - -- an object containing param1=val1 param2=val2 ...

WordBasedAnalyzer

public WordBasedAnalyzer()
Method Detail

setup

public void setup(java.lang.String text)
This method initializes the Analyzer. The text is broken into tokens that are stored in an array. Each token is associated with a pattern -- 'that' has the pattern '1231'. The tokens are sorted with those having the smallest (non empty) pattern set given preference.

Specified by:
setup in interface Analyzer
Overrides:
setup in class CryptoAnalyzer
Parameters:
text - a String pointing to the text being analyzed

init

public void init()
This method is called by setup().


run

public void run()
This method is part of the Analyzer interface. It runs the analysis.

Specified by:
run in interface Analyzer
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class CryptoAnalyzer

getReport

public java.lang.String getReport()
This method is part of the Analyzer interface. It returns the report generated by the analysis.

Specified by:
getReport in interface Analyzer
Overrides:
getReport in class CryptoAnalyzer

toString

public java.lang.String toString()
This method returns the report generated by the analysis.

Overrides:
toString in class CryptoAnalyzer

doAnalysis

public void doAnalysis()
This method performs an analysis of the text. It assumes the text is a word-delimited cryptogram created using a simple substitution cipher. The anlysis is performed by a recursive backtracking search of the key space.