Merge branch 'main' of https://git.vps.francescomancuso.it/elisabetta/cryptoseals
All checks were successful
Deploy / trigger (push) Successful in 30s
All checks were successful
Deploy / trigger (push) Successful in 30s
This commit is contained in:
@@ -6,7 +6,8 @@ public class Caesar {
|
||||
char encoded[] = plaintext.toCharArray();
|
||||
|
||||
for(int i = 0; i < plaintext.length(); i++){
|
||||
encoded[i] = alphabet.charAt(alphabet.indexOf(encoded[i]) + key % 26);
|
||||
if (alphabet.indexOf(encoded[i]) == -1) continue;
|
||||
encoded[i] = alphabet.charAt((alphabet.indexOf(encoded[i]) + key) % 26);
|
||||
}
|
||||
return String.valueOf(encoded);
|
||||
}
|
||||
@@ -21,6 +22,10 @@ public class Caesar {
|
||||
for(int key = 0; key < alphabet.length(); key++){
|
||||
|
||||
for(int i = 0; i < ciphertext.length(); i++){
|
||||
if (alphabet.indexOf(encoded[i]) == -1) {
|
||||
decoded[i] = encoded[i];
|
||||
continue;
|
||||
}
|
||||
char current = encoded[i];
|
||||
int pos = alphabet.indexOf(current);
|
||||
if(pos != -1) {
|
||||
|
||||
Reference in New Issue
Block a user