From 5120dd94be3b7229c9e7ac51081f8d6c98d5d2c5 Mon Sep 17 00:00:00 2001 From: Daniel Zdravkovic <3012893@stud.hs-mannheim.de> Date: Mon, 10 Jun 2024 13:34:52 +0200 Subject: [PATCH] encoding und decoding methods mit Base64 implementiert --- src/main/java/de/hs_mannheim/domain/System.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hs_mannheim/domain/System.java b/src/main/java/de/hs_mannheim/domain/System.java index b91c89e..0b4ea1d 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -11,6 +11,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.TreeSet; +import org.apache.commons.codec.binary.Base64; import org.json.JSONObject; public class System { @@ -39,8 +40,17 @@ public class System { this.current_user.setBike_avg_kmh(bike_avg_kmh); } - public void encoding(String string){ + public void decoding(String string){ + byte[] binary_data = Base64.decodeBase64(string); + string = new String(binary_data); + } + public void encoding(String string){ + byte[] binary_data = new byte[string.length()]; + for(int i = 0; i < string.length(); i++){ + binary_data[i] = (byte) string.charAt(i); + } + string = Base64.encodeBase64String(binary_data); } public HashSet get_all_user() throws FileNotFoundException, IOException{