hcrypto.analyzer.evolutionary
Class NgramGaAnalyzer

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

public class NgramGaAnalyzer
extends GaAnalyzer

Assumes that the text is encrypted with simple substitution cipher and uses a frequency-based genetic algorithm to analyze it.

Its evaluation function uses an NgramArray with frequencies of N = 2, 3, or 4 (bigrams, trigrams, or tetragrams) to cryptanalyze transposition and substitution ciphers. Using the sum of the inverses of the frequencies as an evaluation of how accurately a decrypt matches the usual N-gram frequencies in a language is an idea described by Alex Griffing the developer of the "Automatic Cryptogram Solver". This program is based on R. Walde's NgramClimber.java. To compile and run from the TestAnalyzer application: cd ~crypto/hcryptoj/1.4/applications/testanalyzer javac -classpath ../../classes -d ../../classes ../../source/hcrypto/analyzer/NgramGaAnalyzer.java java -classpath ../../classes:. TestAnalyzer analyzers.NgramAnalyzer ga_paramfiles ngram.ga.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
NgramGaAnalyzer()
          NgramGaAnalyzer() -- Default constructor
NgramGaAnalyzer(GaParameters params, AnalyzerFrame f)
          NgramGaAnalyzer() -- this constructor is given an object containing parameter settings
 
Method Summary
 void run()
          run() conducts the GA run and reports the results.
 void setup(java.lang.String text)
          setup() creates the population for the NgramGa.
 
Methods inherited from class hcrypto.analyzer.CryptoAnalyzer
getReport, prettyPrint, setup, stopThread, threadIsStopped, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NgramGaAnalyzer

public NgramGaAnalyzer()
NgramGaAnalyzer() -- Default constructor


NgramGaAnalyzer

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

Parameters:
params - -- an object containing param1=val1 param2=val2 ...
g - -- the AnalyzerFrame (GUI) for this analyzer
Method Detail

setup

public void setup(java.lang.String text)
setup() creates the population for the NgramGa.

Specified by:
setup in interface Analyzer
Overrides:
setup in class GaAnalyzer

run

public void run()
run() conducts the GA run and reports the results.

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