Merge branch 'main' of https://git.vps.francescomancuso.it/elisabetta/cryptoseals
All checks were successful
Deploy / trigger (push) Successful in 30s

This commit is contained in:
2026-04-29 10:11:02 +02:00

View File

@@ -6,7 +6,8 @@ public class Caesar {
char encoded[] = plaintext.toCharArray(); char encoded[] = plaintext.toCharArray();
for(int i = 0; i < plaintext.length(); i++){ 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); return String.valueOf(encoded);
} }
@@ -21,6 +22,10 @@ public class Caesar {
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++){
if (alphabet.indexOf(encoded[i]) == -1) {
decoded[i] = encoded[i];
continue;
}
char current = encoded[i]; char current = encoded[i];
int pos = alphabet.indexOf(current); int pos = alphabet.indexOf(current);
if(pos != -1) { if(pos != -1) {