package Crypter; import java.util.HashMap; /** * Implementierung des Crypter-Interfaces. */ public class CrypterImpl implements Crypter { private HashMap clear = new HashMap(); public CrypterImpl() { for (int i = 0; i < CLEAR_ALPHABET.length(); i++) { String zw2 = CYPHER_ALPHABET.charAt(i) + ""; String zw1 = CLEAR_ALPHABET.charAt(i) + ""; clear.put(zw1, zw2); } } @Override public String encrypt(String input) { if (input.equals(null)) { return null; } else { input = input.toLowerCase(); String result = ""; for (int i = 0; i < input.length(); i++) { if (clear.containsKey(input.charAt(i) + "")) { result += clear.get(input.charAt(i) + ""); } else if (input.charAt(i) == '!' || input.charAt(i) == '(' || input.charAt(i) == ')' || input.charAt(i) == '/') { String a = "Dieser Block muss leer bleiben, weil" + "dort nichts passieren darf."; } else { result += input.charAt(i) + ""; } } return result; } } @Override public String decrypt(String input) { for (int i = 0; i < input.length(); i++) { if (input.charAt(i) == '!' || input.charAt(i) == 'Ü' || input.charAt(i) == 'Ä' || input.charAt(i) == 'Ö' || input.charAt(i) == '/' || input.charAt(i) == '&' || input.charAt(i) == 'X') { return null; } } return encrypt(input); } }