From c9dd9469183d95c6c2f4d01e3d6365ec57386a65 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:43:46 +0200 Subject: Initial commit --- src/algorithmus/Blabla.java | 116 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 src/algorithmus/Blabla.java (limited to 'src/algorithmus/Blabla.java') diff --git a/src/algorithmus/Blabla.java b/src/algorithmus/Blabla.java new file mode 100755 index 0000000..e459645 --- /dev/null +++ b/src/algorithmus/Blabla.java @@ -0,0 +1,116 @@ +package algorithmus; + +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.UnsupportedEncodingException; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JSpinner; + +public class Blabla extends Algorithmus { + + private String name, pw; + private char[] charset; + + public Blabla() { + name = "Blabla"; + } + + public void options() { + charset = new char[] { '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', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü', 'ß', ' '}; + JFrame frame = new JFrame(); + frame.setLayout(null); + frame.setTitle("Blabla"); + frame.setSize(200, 150); + TextField alphabet = new TextField(); + alphabet.setText("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ÄÖÜäöüß "); + alphabet.setBounds(5, 5, 150, 20); + TextField password = new TextField(); + password.setText("Passwort"); + password.setBounds(5, 30, 150, 20); + JButton apply = new JButton("Speichern"); + apply.setBounds(5, 55, 100, 20); + apply.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + pw = password.getText(); + String alpha = alphabet.getText(); + charset = new char[alpha.length()]; + alpha.getChars(0, alpha.length(), charset, 0); + } + }); + frame.add(alphabet); + frame.add(password); + frame.add(apply); + frame.setVisible(true); + } + + public String getName() { + return name; + } + + public String encode(String input) { + int sum = getSum(pw, "UTF8"), length = input.length(); + String out = ""; + byte[] ba = Utils.fill(new byte[64], length), inba = null; + System.out.println(ba.length); + try { + inba = input.getBytes("UTF8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + 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