From c9dd9469183d95c6c2f4d01e3d6365ec57386a65 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:43:46 +0200 Subject: Initial commit --- .classpath | 6 ++ .gitignore | 171 +++++++++++++++++++++++++++++++++++++++ .project | 17 ++++ .project (1) | 17 ++++ src/Core.java | 8 ++ src/Mainframe.java | 78 ++++++++++++++++++ src/algorithmus/Algorithmus.java | 13 +++ src/algorithmus/Autokey.java | 103 +++++++++++++++++++++++ src/algorithmus/Blabla.java | 116 ++++++++++++++++++++++++++ src/algorithmus/Caesar.java | 96 ++++++++++++++++++++++ src/algorithmus/Case.java | 81 +++++++++++++++++++ src/algorithmus/Constants.java | 13 +++ src/algorithmus/Palisaden.java | 72 +++++++++++++++++ src/algorithmus/Utils.java | 39 +++++++++ src/algorithmus/Vigenere.java | 99 +++++++++++++++++++++++ src/algorithmus/XOR.java | 102 +++++++++++++++++++++++ src/algorithmus/Zaehlen.java | 55 +++++++++++++ 17 files changed, 1086 insertions(+) create mode 100755 .classpath create mode 100644 .gitignore create mode 100755 .project create mode 100755 .project (1) create mode 100755 src/Core.java create mode 100755 src/Mainframe.java create mode 100755 src/algorithmus/Algorithmus.java create mode 100755 src/algorithmus/Autokey.java create mode 100755 src/algorithmus/Blabla.java create mode 100755 src/algorithmus/Caesar.java create mode 100755 src/algorithmus/Case.java create mode 100755 src/algorithmus/Constants.java create mode 100755 src/algorithmus/Palisaden.java create mode 100755 src/algorithmus/Utils.java create mode 100755 src/algorithmus/Vigenere.java create mode 100755 src/algorithmus/XOR.java create mode 100755 src/algorithmus/Zaehlen.java diff --git a/.classpath b/.classpath new file mode 100755 index 0000000..63b7e89 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d02df8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,171 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/eclipse,java,windows,linux,macos +# Edit at https://www.toptal.com/developers/gitignore?templates=eclipse,java,windows,linux,macos + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +### Eclipse Patch ### +# Spring Boot Tooling +.sts4-cache/ + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/eclipse,java,windows,linux,macos diff --git a/.project b/.project new file mode 100755 index 0000000..5a0ce15 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Kryptographie + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.project (1) b/.project (1) new file mode 100755 index 0000000..5a0ce15 --- /dev/null +++ b/.project (1) @@ -0,0 +1,17 @@ + + + Kryptographie + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/src/Core.java b/src/Core.java new file mode 100755 index 0000000..b965eff --- /dev/null +++ b/src/Core.java @@ -0,0 +1,8 @@ + +public class Core { + + public static void main(String[] args) { + new Mainframe().setVisible(true); + } + +} diff --git a/src/Mainframe.java b/src/Mainframe.java new file mode 100755 index 0000000..e486e2a --- /dev/null +++ b/src/Mainframe.java @@ -0,0 +1,78 @@ +import java.awt.TextArea; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import algorithmus.Algorithmus; +import algorithmus.Autokey; +import algorithmus.Blabla; +import algorithmus.Caesar; +import algorithmus.Case; +import algorithmus.Palisaden; +import algorithmus.Vigenere; +import algorithmus.XOR; +import algorithmus.Zaehlen; + + +public class Mainframe extends JFrame { + + private JTextArea input, output; + private JScrollPane scrollInput, scrollOutput; + private JComboBox combo; + private JButton options, encode, decode; + private Algorithmus[] algo = new Algorithmus[] { new Case(), new Caesar(), new Blabla(), new Zaehlen(), new Vigenere(), new XOR(), new Autokey(), new Palisaden() }; + + public Mainframe() { + this.setLayout(null); + this.setResizable(false); + this.setTitle("Kryptographie"); + this.setSize(500, 500); + input = new JTextArea(); + input.setLineWrap(true); + scrollInput = new JScrollPane(input); + scrollInput.setBounds(5, 5, 470, 205); + output = new JTextArea(); + output.setEditable(false); + output.setLineWrap(true); + scrollOutput = new JScrollPane(output); + scrollOutput.setBounds(5, 245, 470, 205); + String[] names = new String[algo.length]; + for(int i = 0; i=0; i--) { + bin = Utils.fill(input.substring((i*64)-64, (i*64)).getBytes("UTF8"), 64); + sum = bin.length * 64; + for(int x = bin.length; x>0; x--) { + str += Constants.LETTERS_NUMBERS[(sum-=(bin[x]+x))%62]; + } + } + } catch(UnsupportedEncodingException e) { + e.printStackTrace(); + } + return str; + } + + public int getSum(String str, String charset) { + int sum = 0; + byte[] ba = new byte[] { (byte)0x00 }; + try { + ba = str.getBytes(charset); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + for(int i = 0; i 96 && ba[i] < 123) + ba[i] -= 32; + return ba; + } + + private byte[] lower(byte[] ba) { + for(int i = 0; i 64 && ba[i] < 91) + ba[i] += 32; + return ba; + } + +} diff --git a/src/algorithmus/Constants.java b/src/algorithmus/Constants.java new file mode 100755 index 0000000..87772d0 --- /dev/null +++ b/src/algorithmus/Constants.java @@ -0,0 +1,13 @@ +package algorithmus; + +public class Constants { + + public static final char[] HEX_CHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + public static final char[] LETTERS_NUMBERS = new char[] { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' + }; + +} diff --git a/src/algorithmus/Palisaden.java b/src/algorithmus/Palisaden.java new file mode 100755 index 0000000..fa822d4 --- /dev/null +++ b/src/algorithmus/Palisaden.java @@ -0,0 +1,72 @@ +package algorithmus; + +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JSpinner; + +public class Palisaden extends Algorithmus { + + private String name; + private int n; + + public Palisaden() { + name = "Palisaden"; + n = 3; + } + + @Override + public void options() { + JFrame frame = new JFrame(); + frame.setLayout(null); + frame.setTitle("Palisaden"); + frame.setSize(200, 150); + JLabel label = new JLabel("Reihen:"); + label.setBounds(5, 30, 100, 20); + JSpinner spinner = new JSpinner(); + spinner.setBounds(100, 30, 50, 20); + spinner.setValue(n); + JButton apply = new JButton("Speichern"); + apply.setBounds(5, 55, 100, 20); + apply.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + n = (int) spinner.getValue(); + } + }); + frame.add(label); + frame.add(spinner); + frame.add(apply); + frame.setVisible(true); + } + + @Override + public String getName() { + return name; + } + + @Override + public String encode(String input) { + String out = ""; + int length = input.length(); + String[] rows = new String[n]; + for(int i = 0; i