Cifrario di Cesare
-
Sposta le lettere dell'alfabeto di un numero fisso di posizioni. Semplice, storico, ma efficace per messaggi veloci.
-
+
Sposta le lettere dell'alfabeto di un numero fisso di posizioni. Semplice, storico, ma
+ efficace per messaggi veloci.
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
\ No newline at end of file
diff --git a/backend/src/main/resources/get/cesare.js b/backend/src/main/resources/get/cesare.js
new file mode 100644
index 0000000..a008211
--- /dev/null
+++ b/backend/src/main/resources/get/cesare.js
@@ -0,0 +1,30 @@
+async function encrypt() {
+ const plaintext = document.getElementById("plaintext").value;
+ const key = document.getElementById("key").value;
+
+ if(!plaintext) return alert("Inserisci del testo!");
+
+ try {
+ const risposta = await fetch("/seal/cesare/encrypt", {
+ method: "POST", headers: { "Content-Type": "application/json" },
+ // Invia il testo e la chiave (convertita in numero) al server
+ body: JSON.stringify({ plaintext: plaintext, key: parseInt(key) })
+ });
+ document.getElementById("ciphertext").value = await risposta.text();
+ } catch (e) { alert("Errore di connessione con le API di Cesare!"); }
+ }
+
+ async function decrypt() {
+ const ciphertext = document.getElementById("ciphertext").value;
+ const key = document.getElementById("key").value;
+
+ if(!ciphertext) return alert("Nessun testo da decifrare!");
+ try {
+ const res = await fetch("/seal/cesare/decrypt", {
+ method: "POST", headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ testo: ciphertext, chiave: parseInt(key) })
+ });
+ // TODO: SISTEMARE IL SISTEMA DI DECIFRATURA !!
+ document.getElementById("testoDecifrato").value = await res.text();
+ } catch (e) { alert("Errore di connessione!"); }
+ }
\ No newline at end of file
diff --git a/backend/src/main/resources/get/index.html b/backend/src/main/resources/get/index.html
index 1b0693f..64fb8f9 100644
--- a/backend/src/main/resources/get/index.html
+++ b/backend/src/main/resources/get/index.html
@@ -6,12 +6,13 @@