Compare commits

...

2 Commits

Author SHA1 Message Date
532ecd47b6 idk how to read actually
All checks were successful
Deploy / trigger (push) Successful in 24s
2026-04-20 22:55:18 +02:00
080c067f27 will it work?? 2026-04-20 22:53:49 +02:00

View File

@@ -14,13 +14,22 @@ public class Caesar {
public static String[] decode(String ciphertext){ public static String[] decode(String ciphertext){
String alphabet = "abcdefghijklmnopqrstuvwxyz"; String alphabet = "abcdefghijklmnopqrstuvwxyz";
char encoded[] = ciphertext.toCharArray(); char encoded[] = ciphertext.toCharArray();
char decoded[] = new char[ciphertext.length()]; char decoded[] = new char[ciphertext.length()];
String bruteforce[] = new String[26]; String bruteforce[] = new String[26];
for(int key = 0; key < alphabet.length(); key++){ for(int key = 0; key < alphabet.length(); key++){
for(int i = 0; i < ciphertext.length(); i++){ for(int i = 0; i < ciphertext.length(); i++){
decoded[i] = alphabet.charAt(alphabet.indexOf((encoded[i] + key) % 26)); char current = encoded[i];
int pos = alphabet.indexOf(current);
if(pos != -1) {
int newpos = (pos + key) % 26;
decoded[i] = alphabet.charAt(newpos);
} else
decoded[i] = current;
} }
bruteforce[key] = String.valueOf(encoded); bruteforce[key] = String.valueOf(decoded);
} }
return bruteforce; return bruteforce;