/** * File: Keys.java * @author A.Kurd * * Description: Implements a Java 1.1 version of a GUI tool for creating possible keys. Most of this is similar to the methods * used throughout this program. The difference being that the keys have final values. * Credits: This program is modelled after the frequency test of the CryptoToolJ program by Ralph Morelli. * * Copyright: This program is in the public domain. You can do whatever you want with * it as long as I get credit for my work and as long as you offer your changes to me * so I can possible add them to the "official" version. */ package analyzers; // Analyzer plugins belong to this package import hcrypto.analyzer.*; // This is where Analyzer is import java.awt.TextArea; import hcrypto.cipher.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class Keys extends Frame implements WindowListener, Analyzer{ public Frame frame[] = new Frame[10]; //the frames that the top 10 KeyGroups are displayed public Random rand = new Random(); public KeyBuilder kb= new KeyBuilder(); //to count letter frequency public Calculate ct = new Calculate(); //to score the different KeyGroups public BigramCount bc= new BigramCount(); //to collect Bigram data public TrigramCount tc = new TrigramCount(); //to collect Trigram data public KeyGroups kg = new KeyGroups(); //to create possible KeyGroups public String output [] = new String [10]; //The 10 strings were the output is collected public int result [] = new int[128]; //array to collect the order of letters for the KeyGroup public int TriFreq[][] = new int[128][3]; //for changing Trigram frequencies[] from chars to ints public int resultKey [] = new int[128]; //for storing possible keys public int random1[] = {1,2,3,4,5,6,7,8}; //for ordering groups 2 thru 5 into keys from KeyGroups public int random2[] = {1,2}; public int random3[] = {1,2,3,4,5,6,7,8,9}; public int random4[] = {1,2,3}; private TextArea text1; // Pointers to the text to be analyzed private TextArea display1; // And the window where results are displayed public TextArea display [] = new TextArea[10]; //different display areas public char freqI [] = {'e','t', 'a', 'o', 'i', 'n', 's', 'h', 'r', 'd', 'l', 'c', 'u', 'm', 'w', 'f', 'g', 'y', 'p', 'b','v', 'k', 'j', 'x', 'q', 'z'};//order of letters by frequency public int total [] = new int [10]; //scores of KeyGroups public int rating [] = new int [10]; //scores of "candidate" keys public void Keys(String text){ }//BigramDisplay //necessary for the analysis package public void setup(TextArea text1, TextArea display1) { this.text1 = text1; this.display1 = display1; }//setup public void run() { display1.append("Keys activated" + "\n"); int n = 1; int l =0; kb.count(text1.getText()); bc.count(text1.getText()); tc.count(text1.getText()); for(int i=0; i<12; i++) if(tc.frequencies[i] != null){ TriFreq[i][0] = (int)tc.frequencies[i][0]; TriFreq[i][1] = (int)tc.frequencies[i][1]; TriFreq[i][2] = (int)tc.frequencies[i][2];}//if for( int i = 0; i<10; i++){ create(i); score(i,result);}//for int k = total[0]; for(int j = 1; j<10; j++){ if(k greatest){ greatest = r[i]; position = i;}//if }//for display1.append("the value of the most probable key is: " + greatest + " at Key" + (position+1) + "\n"); }//probable public int[] create(int i){ if(i == 0){ for(int k = 0; k