This commit is contained in:
@@ -14,15 +14,15 @@ public class Seal {
|
||||
|
||||
System.out.println("Generazione chiavi RSA per il server web in corso...");
|
||||
|
||||
// Cifratura con Cifrario di Cesare
|
||||
app.post("/seal/caesar/encrypt", ctx -> {
|
||||
// Cifratura con Cifrario di Vigenere
|
||||
app.post("/seal/vigenere/encrypt", ctx -> {
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
// Decifratura con Cifrario di Vigenere
|
||||
app.post("/seal/vigenere/encrypt", ctx -> {
|
||||
// Cifratura con Cifrario di Cesare
|
||||
app.post("/seal/caesar/encrypt", ctx -> {
|
||||
RichiestaCesare req = ctx.bodyAsClass(RichiestaCesare.class);
|
||||
String ciphertext = Caesar.encode(req.plaintext,req.key);
|
||||
ctx.result(ciphertext);
|
||||
|
||||
@@ -5,13 +5,13 @@ async function encrypt() {
|
||||
if (!plaintext) return alert("Inserisci del testo!");
|
||||
|
||||
try {
|
||||
const risposta = await fetch("/seal/cesare/encrypt", {
|
||||
const risposta = await fetch("/seal/caesar/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!"); }
|
||||
} catch (e) { alert("Errore di connessione con le API di caesar!"); }
|
||||
}
|
||||
|
||||
async function decrypt() {
|
||||
@@ -20,7 +20,7 @@ async function decrypt() {
|
||||
|
||||
if (!ciphertext) return alert("Nessun testo da decifrare!");
|
||||
try {
|
||||
const res = await fetch("/seal/cesare/decrypt", {
|
||||
const res = await fetch("/seal/caesar/decrypt", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ testo: ciphertext, chiave: parseInt(key) })
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user