will it work??
This commit is contained in:
@@ -14,11 +14,20 @@ public class Caesar {
|
||||
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));
|
||||
char current = encoded[i];
|
||||
int pos = alphabet.indexOf(current);
|
||||
if(pos != -1) {
|
||||
int newpos = alphabet.indexOf((pos + key) % 26);
|
||||
decoded[i] = alphabet.charAt(newpos);
|
||||
} else
|
||||
decoded[i] = current;
|
||||
}
|
||||
bruteforce[key] = String.valueOf(encoded);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user