async function encrypt() { const plaintext = document.getElementById("plaintext").value; const size = document.getElementById("keysize").value; if (!plaintext) return alert("Per favore, inserisci del testo da cifrare."); document.getElementById("ciphertext").value = "Le foche stanno cifrando... Attendere prego."; try { const res = await fetch("/seal/rsa/encrypt", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: plaintext, keysize: parseInt(size) }) }); document.getElementById("ciphertext").value = await res.text(); } catch (e) { alert("Impossibile connettersi al server Javalin."); } } async function decrypt() { const input = document.getElementById("ciphertext").value; if (!input) return alert("Non c'รจ nessun testo da decifrare."); document.getElementById("decodedtext").value = "Decifratura in corso..."; try { // NOTA: Controlla che la rotta nel tuo Java sia corretta (/seal/rsa/decrypt o /api/rsa/decifra) const res = await fetch("http://localhost:8080/seal/rsa/decrypt", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: input }) }); document.getElementById("decodedtext").value = await res.text(); } catch (e) { alert("Impossibile connettersi al server."); } } // Gestione Menu Mobile function toggleMenu() { document.getElementById("nav-links").classList.toggle("active"); } // Anno dinamico Footer document.getElementById("year").innerText = new Date().getFullYear();