This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>CryptoSeals - RSA</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="rsa.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -56,41 +57,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
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 {
|
||||
// NOTA: Controlla che la rotta nel tuo Java sia corretta (/seal/rsa/encrypt o /api/rsa/cifra)
|
||||
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."); }
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user