This commit is contained in:
157
backend/src/main/resources/get/index.html
Normal file
157
backend/src/main/resources/get/index.html
Normal file
@@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CryptoSeals - Motore RSA</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar">
|
||||
<a href="index.html" class="nav-brand">
|
||||
<img src="seal1.png" height="50" alt="🦭" onerror="this.src='https://cdn-icons-png.flaticon.com/512/3063/3063126.png';">
|
||||
CryptoSeals
|
||||
</a>
|
||||
<div class="menu-toggle" onclick="toggleMenu()">
|
||||
<i class="fa-solid fa-bars"></i>
|
||||
</div>
|
||||
<ul class="nav-links" id="nav-links">
|
||||
<li><a href="rsa.html" class="active"><i class="fa-solid fa-key"></i> RSA</a></li>
|
||||
<li><a href="cesare.html"><i class="fa-solid fa-arrow-right-arrow-left"></i> Cesare</a></li>
|
||||
<li><a href="vigenere.html"><i class="fa-solid fa-table"></i> Vigenère</a></li>
|
||||
<li><a href="team.html"><i class="fa-solid fa-users"></i> 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><i class="fa-solid fa-ruler-horizontal"></i> Dimensione Chiave RSA</label>
|
||||
<select id="keysize" style="margin-top: 5px; margin-bottom: 20px;">
|
||||
<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><i class="fa-solid fa-pen"></i> Testo in chiaro</label>
|
||||
<textarea id="plaintext" placeholder="Scrivi il messaggio segreto che vuoi proteggere..."></textarea>
|
||||
<button id="btn-encrypt" onclick="encrypt()"><i class="fa-solid fa-lock"></i> Cifra il messaggio</button>
|
||||
</div>
|
||||
|
||||
<div class="crypto-col">
|
||||
<label><i class="fa-solid fa-barcode"></i> Testo Cifrato (Base64)</label>
|
||||
<textarea id="ciphertext" placeholder="Il testo protetto apparirà qui..."></textarea>
|
||||
<button id="btn-decrypt" class="btn-green" onclick="decrypt()"><i class="fa-solid fa-unlock-keyhole"></i> Decifra il messaggio</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="margin-top: 35px;">
|
||||
<label><i class="fa-solid fa-check-double"></i> Risultato finale decifrato</label>
|
||||
<textarea id="decodedtext" readonly placeholder="Il messaggio originale apparirà qui dopo la decifratura..." style="height: 100px; background-color: rgba(16, 185, 129, 0.1); border-color: var(--accent-green); color: var(--accent-green);"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleMenu() {
|
||||
document.getElementById("nav-links").classList.toggle("active");
|
||||
}
|
||||
|
||||
// Configurazione globale per SweetAlert2 in tema dark
|
||||
const Toast = Swal.mixin({
|
||||
background: '#1f2937',
|
||||
color: '#f3f4f6',
|
||||
confirmButtonColor: '#10b981'
|
||||
});
|
||||
|
||||
async function encrypt() {
|
||||
const plaintext = document.getElementById("plaintext").value;
|
||||
const size = document.getElementById("keysize").value;
|
||||
const btn = document.getElementById("btn-encrypt");
|
||||
|
||||
if(!plaintext) {
|
||||
return Toast.fire({ icon: "warning", title: "Attenzione", text: "Per favore, inserisci del testo da cifrare." });
|
||||
}
|
||||
|
||||
// Stato di caricamento UI
|
||||
btn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Cifratura in corso...';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
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) })
|
||||
});
|
||||
|
||||
if(!res.ok) throw new Error("Errore Server");
|
||||
|
||||
document.getElementById("ciphertext").value = await res.text();
|
||||
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: 'Completato!',
|
||||
text: 'Il messaggio è stato cifrato con successo.',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
Toast.fire({ icon: "error", title: "Errore di connessione", text: "Impossibile connettersi al server Javalin. Controlla che sia avviato!" });
|
||||
} finally {
|
||||
// Ripristino bottone
|
||||
btn.innerHTML = '<i class="fa-solid fa-lock"></i> Cifra il messaggio';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function decrypt() {
|
||||
const input = document.getElementById("ciphertext").value;
|
||||
const btn = document.getElementById("btn-decrypt");
|
||||
|
||||
if(!input) {
|
||||
return Toast.fire({ icon: "warning", title: "Attenzione", text: "Non c'è nessun testo cifrato da decodificare." });
|
||||
}
|
||||
|
||||
// Stato di caricamento UI
|
||||
btn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Decifratura in corso...';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
const res = await fetch("http://localhost:8080/seal/rsa/decrypt", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ text: input })
|
||||
});
|
||||
|
||||
if(!res.ok) throw new Error("Errore Server");
|
||||
|
||||
document.getElementById("decodedtext").value = await res.text();
|
||||
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: 'Decifrato!',
|
||||
text: 'Messaggio originale recuperato.',
|
||||
timer: 2000,
|
||||
showConfirmButton: false
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
Toast.fire({ icon: "error", title: "Errore", text: "Impossibile decifrare. Il testo potrebbe essere corrotto o il server offline." });
|
||||
} finally {
|
||||
// Ripristino bottone
|
||||
btn.innerHTML = '<i class="fa-solid fa-unlock-keyhole"></i> Decifra il messaggio';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user