This commit is contained in:
@@ -10,4 +10,19 @@ public class Caesar {
|
||||
}
|
||||
return String.valueOf(encoded);
|
||||
}
|
||||
|
||||
public static String[] decode(String ciphertext){
|
||||
String alphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||
char encoded[] = ciphertext.toCharArray();
|
||||
char decoded[] = new char[ciphertext.length()];
|
||||
String bruteforce[] = new String[26];
|
||||
for(int key = 0; key < alphabet.length(); key++){
|
||||
for(int i = 0; i < ciphertext.length(); i++){
|
||||
decoded[i] = alphabet.charAt(alphabet.indexOf(encoded[i]) + key % 26);
|
||||
}
|
||||
bruteforce[key] = String.valueOf(encoded);
|
||||
}
|
||||
return bruteforce;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user