silly hover
All checks were successful
Deploy / trigger (push) Successful in 36s

This commit is contained in:
2026-03-31 12:32:41 +02:00
parent cc326efd03
commit 3e5d359282
3 changed files with 30 additions and 16 deletions

View File

@@ -1,18 +1,13 @@
package com.crypto;
import java.util.Scanner;
public class Caesar {
public static void encode(Scanner sc){
public static String encode(String plaintext, int key){
String alphabet = "abcdefghijklmnopqrstuvwxyz";
System.out.println("Digita il testo in chiaro da cifrare:");
String base = sc.nextLine();
System.out.println("Digita il valore della chiave:");
int key = sc.nextInt();
char encoded[] = base.toCharArray();
char encoded[] = plaintext.toCharArray();
for(int i = 0; i < base.length(); i++){
for(int i = 0; i < plaintext.length(); i++){
encoded[i] = alphabet.charAt(alphabet.indexOf(encoded[i]) + key % 26);
}
System.out.println(encoded);
return encoded.toString();
}
}

View File

@@ -23,7 +23,9 @@ public class Seal {
// Decifratura con Cifrario di Vigenere
app.post("/seal/vigenere/encrypt", ctx -> {
RichiestaCesare req = ctx.bodyAsClass(RichiestaCesare.class);
String ciphertext = Caesar.encode(req.plaintext,req.key);
ctx.result(ciphertext);
}
);
@@ -31,7 +33,7 @@ public class Seal {
// Cifratura con RSA
app.post("/seal/rsa/encrypt", ctx -> {
// Legge i dati nel body dalla richiesta
Richiesta req = ctx.bodyAsClass(Richiesta.class);
RichiestaRSA req = ctx.bodyAsClass(RichiestaRSA.class);
RSA.RSAkeys keys = RSA.defkeys(req.keysize / 2);
String ciphertext = RSA.encrypt(req.text,keys.e(), keys.n());
ctx.result("{\"ciphertext\":\""+ciphertext+"\",\"keys\":{\"d\":\"" + keys.d().toString() + "\",\"n\":\"" + keys.n().toString() + "\"}}");
@@ -40,7 +42,7 @@ public class Seal {
// Decifratura con RSA
app.post("/seal/rsa/decrypt", ctx -> {
// Legge i dati nel body dalla richiesta
Richiesta req = ctx.bodyAsClass(Richiesta.class);
RichiestaRSA req = ctx.bodyAsClass(RichiestaRSA.class);
BigInteger d = new BigInteger(req.d);
BigInteger n = new BigInteger(req.n);
@@ -49,18 +51,25 @@ public class Seal {
String plaintext = RSA.decrypt(req.text, d, n);
// Restituisce il risultato della cifratura
ctx.result(plaintext.replaceAll("\\\\u0000/g", ""));
ctx.result(plaintext.replace("\u0000", "").trim());
});
}
}
// Classe utilizzata per tradurre il JSON - Rappresenta l'oggetto richiesta
class Richiesta {
// Classi utilizzate per tradurre il JSON - Rappresenta l'oggetto richiesta
class RichiestaCesare {
public int key;
public String plaintext;
// Costruttore della richiesta
}
class RichiestaRSA {
public int keysize;
public String text;
public String d;
public String n;
// Costruttore della richiesta
public Richiesta() {}
public RichiestaRSA() {}
}

View File

@@ -54,6 +54,16 @@ body {
.nav-brand img {
border-radius: 50%;
height: 40px;
width: 80px;
object-fit: cover;
}
.nav-brand img:hover {
object-fit: fill;
display: inline-block;
margin-top: 10px;
margin-bottom: -10px;
}
.nav-links {