trying to fix the interface
All checks were successful
Deploy / trigger (push) Successful in 40s

This commit is contained in:
2026-03-28 11:18:42 +01:00
parent 0e370eb457
commit d371b504f5
6 changed files with 90 additions and 91 deletions

View File

@@ -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!"); }
}