Signed-off-by: Francesco Mancuso <hello@francescomancuso.it>
This commit is contained in:
@@ -6,7 +6,7 @@ public class Caesar {
|
||||
char encoded[] = plaintext.toCharArray();
|
||||
|
||||
for(int i = 0; i < plaintext.length(); i++){
|
||||
if (encoded[i] == ' ') continue;
|
||||
if (alphabet.indexOf(encoded[i]) == -1) continue;
|
||||
encoded[i] = alphabet.charAt((alphabet.indexOf(encoded[i]) + key) % 26);
|
||||
}
|
||||
return String.valueOf(encoded);
|
||||
@@ -22,7 +22,7 @@ public class Caesar {
|
||||
for(int key = 0; key < alphabet.length(); key++){
|
||||
|
||||
for(int i = 0; i < ciphertext.length(); i++){
|
||||
if (encoded[i] == ' ') {
|
||||
if (alphabet.indexOf(encoded[i]) == -1) {
|
||||
decoded[i] = encoded[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user