95 lines
4.5 KiB
HTML
95 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="it">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>CryptoSeals - RSA</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar">
|
|
<a href="index.html" class="nav-brand">
|
|
<span><img src="seal1.png" height="80"onerror="this.style.display='none'; this.nextElementSibling.style.display='inline';"></span> CryptoSeals
|
|
</a>
|
|
<ul class="nav-links">
|
|
<li><a href="rsa.html" class="active">Algoritmo RSA</a></li>
|
|
<li><a href="cesare.html">Cesare</a></li>
|
|
<li><a href="vigenere.html">Vigenère</a></li>
|
|
<li><a href="storia.html">La Storia</a></li>
|
|
<li><a href="team.html">Il Team</a></li>
|
|
</ul>
|
|
</nav>
|
|
|
|
<div class="container">
|
|
<h1>Motore RSA</h1>
|
|
<p class="descrizione">Cifra e decifra i tuoi messaggi con lo standard di sicurezza a chiave pubblica. Scegli la dimensione delle chiavi, scrivi e lascia fare alle foche.</p>
|
|
|
|
<div class="crypto-box">
|
|
|
|
<label>Dimensione Chiave RSA</label>
|
|
<select id="keysize">
|
|
<option value="512">512 bit (Solo didattico - Veloce)</option>
|
|
<option value="1024" selected>1024 bit (Test - Bilanciato)</option>
|
|
<option value="2048">2048 bit (Standard - Lenta da generare ⏳)</option>
|
|
<option value="4096">4096 bit (Alta sicurezza - Molto lenta ⏳⏳)</option>
|
|
</select>
|
|
|
|
<div class="crypto-columns">
|
|
|
|
<div class="crypto-col">
|
|
<label>Testo in chiaro</label>
|
|
<textarea id="plaintext" class="pulse-textarea" placeholder="Scrivi il messaggio segreto che vuoi proteggere..."></textarea>
|
|
<button onclick="encrypt()">🔒 Cifra il messaggio</button>
|
|
</div>
|
|
|
|
<div class="crypto-col">
|
|
<label>Testo Cifrato (Base64)</label>
|
|
<textarea id="ciphertext" placeholder="Il testo protetto apparirà qui..."></textarea>
|
|
<button class="btn-green" onclick="decrypt()">🔓 Decifra il messaggio</button>
|
|
</div>
|
|
|
|
</div>
|
|
<div style="margin-top: 35px;">
|
|
<label>Risultato finale decifrato</label>
|
|
<textarea id="decodedtext" readonly placeholder="Il messaggio originale apparirà qui dopo la decifratura..." style="height: 100px; background-color: #0b0f19; border-color: rgba(16, 185, 129, 0.3); color: #10b981;"></textarea>
|
|
</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("http://localhost:8080/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> |