-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
1,949 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/java/org/kryptojagd/cryptotools/CryptoTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package org.kryptojagd.cryptotools; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.chart.BarChart; | ||
import javafx.scene.chart.CategoryAxis; | ||
import javafx.scene.chart.NumberAxis; | ||
import javafx.scene.chart.XYChart; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.scene.layout.HBox; | ||
import javafx.stage.Stage; | ||
|
||
public class CryptoTool extends Application { | ||
|
||
@Override public void start(Stage stage) throws IOException { | ||
|
||
// haeufigkeitsanalyse(stage); | ||
vigenere(stage); | ||
//karski(stage); | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
//FrequencyAnalysis f = new FrequencyAnalysis(); | ||
// f.initialize(); | ||
} | ||
|
||
public static void caesar(Stage stage) throws IOException { | ||
stage.setResizable(false); | ||
stage.setTitle("Häufigkeitsanalyse"); | ||
|
||
String testText = "EJFT JTU FJO CFJTQJFMUFYU EFS NJU FJOFN LMJDL WFSTDIMÜTTFMU XFSEFO LBOO. " | ||
+ "IJFS LBOO BVDI FJO FJHFOFO UFYU IFSFJO HFTDISJFCFO, PEFS FJO HFIFJNDPEF AVN " | ||
+ "FOUTDIMÜTTFMO IFSFJO LPQJFSU XFSEFO."; | ||
|
||
|
||
FrequencyAnalysisController.setText(testText); | ||
//FrequencyAnalysisController2.setText(testText); | ||
|
||
// Parent root = FXMLLoader.load(getClass().getResource("vigenere.fxml")); | ||
Parent root = FXMLLoader.load(CryptoTool.class.getResource("frequencyAnalysis.fxml")); | ||
//Parent root = FXMLLoader.load(getClass().getResource("frequencyAnalysis2.fxml")); | ||
Scene scene = new Scene(root); | ||
|
||
// Scene scene = new Scene(bc,800,450); | ||
|
||
|
||
stage.setScene(scene); | ||
stage.show(); | ||
|
||
} | ||
|
||
public static void vigenere(Stage stage) throws IOException { | ||
stage.setResizable(false); | ||
stage.setTitle("Häufigkeitsanalyse"); | ||
|
||
String testText = "EJFT JTU FJO CFJTQJFMUFYU EFS NJU FJOFN LMJDL WFSTDIMÜTTFMU XFSEFO LBOO. " | ||
+ "IJFS LBOO BVDI FJO FJHFOFO UFYU IFSFJO HFTDISJFCFO, PEFS FJO HFIFJNDPEF ZVN " | ||
+ "FOUTDIMÜTTFMO IFSFJO LPQJFSU XFSEFO."; | ||
|
||
|
||
FrequencyAnalysisController.setText(testText); | ||
//FrequencyAnalysisController2.setText(testText); | ||
|
||
Parent root = FXMLLoader.load(CryptoTool.class.getResource("vigenere.fxml")); | ||
//Parent root = FXMLLoader.load(getClass().getResource("frequencyAnalysis.fxml")); | ||
//Parent root = FXMLLoader.load(getClass().getResource("frequencyAnalysis2.fxml")); | ||
Scene scene = new Scene(root); | ||
|
||
// Scene scene = new Scene(bc,800,450); | ||
|
||
|
||
stage.setScene(scene); | ||
stage.show(); | ||
|
||
} | ||
|
||
public void karski(Stage stage) throws IOException { | ||
stage.setResizable(false); | ||
stage.setTitle("Häufigkeitsanalyse"); | ||
|
||
String testText = "EJFT JTU FJO CFJTQJFMUFYU EFS NJU FJOFN LMJDL WFSTDIMÜTTFMU XFSEFO LBOO. " | ||
+ "IJFS LBOO BVDI FJO FJHFOFO UFYU IFSFJO HFTDISJFCFO, PEFS FJO HFIFJNDPEF ZVN " | ||
+ "FOUTDIMÜTTFMO IFSFJO LPQJFSU XFSEFO."; | ||
|
||
|
||
FrequencyAnalysisController.setText(testText); | ||
//FrequencyAnalysisController2.setText(testText); | ||
|
||
Parent root = FXMLLoader.load(getClass().getResource("karskiText.fxml")); | ||
// Parent root = FXMLLoader.load(getClass().getResource("frequencyAnalysis.fxml")); | ||
//Parent root = FXMLLoader.load(getClass().getResource("frequencyAnalysis2.fxml")); | ||
Scene scene = new Scene(root); | ||
|
||
// Scene scene = new Scene(bc,800,450); | ||
|
||
|
||
stage.setScene(scene); | ||
stage.show(); | ||
|
||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/kryptojagd/cryptotools/CustomBarChart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.kryptojagd.cryptotools; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.scene.Node; | ||
import javafx.scene.chart.Axis; | ||
import javafx.scene.chart.BarChart; | ||
|
||
public class CustomBarChart<X, Y> extends BarChart<X, Y> { | ||
|
||
public CustomBarChart(Axis<X> xAxis, Axis<Y> yAxis) { | ||
super(xAxis, yAxis); | ||
// TODO Auto-generated constructor stub | ||
// this.getPlotChildren(); | ||
|
||
} | ||
|
||
@Override | ||
public ObservableList<Node> getChartChildren() { | ||
return super.getChartChildren(); | ||
} | ||
|
||
@Override | ||
public ObservableList<Node> getChildren() { | ||
return super.getChildren(); | ||
} | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/org/kryptojagd/cryptotools/FrequencyAnalysis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.kryptojagd.cryptotools; | ||
|
||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
|
||
public class FrequencyAnalysis { | ||
|
||
|
||
public static HashMap<String,Double> absoluteFrequency(String text) { | ||
|
||
HashMap<String,Double> hashmap = new HashMap<String, Double>(); | ||
text = removeCharacters(text); | ||
|
||
char c = 'A'; | ||
for (char letter = 'A'; letter <= 'Z'; letter++) { | ||
hashmap.put(String.valueOf(letter), 0.0); | ||
} | ||
|
||
for (char letter : text.toCharArray()) { | ||
double a = hashmap.get(String.valueOf(letter)) + 1.0; | ||
hashmap.put(String.valueOf(letter), a); | ||
} | ||
|
||
return hashmap; | ||
} | ||
|
||
public static LinkedHashMap<String,Double> relativeFrequency(String text) { | ||
|
||
LinkedHashMap<String,Double> hashmap = new LinkedHashMap<String, Double>(); | ||
text = removeCharacters(text); | ||
double length = (double) text.length(); | ||
|
||
char c = 'A'; | ||
for (char letter = 'A'; letter <= 'Z'; letter++) { | ||
hashmap.put(String.valueOf(letter), 0.0); | ||
} | ||
|
||
for (char letter : text.toCharArray()) { | ||
double a = hashmap.get(String.valueOf(letter)) + (1 / length) * 100; | ||
hashmap.put(String.valueOf(letter), a); | ||
} | ||
|
||
return hashmap; | ||
} | ||
|
||
|
||
|
||
public static LinkedHashMap<String, Double> germanLetterFrequency() { | ||
LinkedHashMap<String,Double> germanLetterFrequency = new LinkedHashMap<String, Double>(); | ||
|
||
germanLetterFrequency.put("E", 17.4); | ||
germanLetterFrequency.put("N", 9.78); | ||
germanLetterFrequency.put("I", 7.55); | ||
germanLetterFrequency.put("S", 7.27); | ||
germanLetterFrequency.put("R", 7.0); | ||
germanLetterFrequency.put("A", 6.51); | ||
germanLetterFrequency.put("T", 6.15); | ||
germanLetterFrequency.put("D", 5.08); | ||
germanLetterFrequency.put("H", 4.76); | ||
germanLetterFrequency.put("U", 4.35); | ||
germanLetterFrequency.put("L", 3.44); | ||
germanLetterFrequency.put("C", 3.06); | ||
germanLetterFrequency.put("G", 3.01); | ||
germanLetterFrequency.put("M", 2.53); | ||
germanLetterFrequency.put("O", 2.51); | ||
germanLetterFrequency.put("B", 1.89); | ||
germanLetterFrequency.put("W", 1.89); | ||
germanLetterFrequency.put("F", 1.66); | ||
germanLetterFrequency.put("K", 1.21); | ||
germanLetterFrequency.put("Z", 1.13); | ||
germanLetterFrequency.put("P", 0.79); | ||
germanLetterFrequency.put("V", 0.67); | ||
// germanLetterFrequency.put("ß", 0.31); | ||
germanLetterFrequency.put("J", 0.27); | ||
germanLetterFrequency.put("Y", 0.04); | ||
germanLetterFrequency.put("X", 0.03); | ||
germanLetterFrequency.put("Q", 0.02); | ||
|
||
return germanLetterFrequency; | ||
} | ||
|
||
private static String removeCharacters(String text) { | ||
|
||
text = text.replaceAll("[^A-Z]", ""); | ||
return text; | ||
} | ||
|
||
} |
Oops, something went wrong.