Skip to content

Instantly share code, notes, and snippets.

@salvatorecapolupo
Created October 31, 2025 15:37
Show Gist options
  • Select an option

  • Save salvatorecapolupo/42fdc07cbff82651dbb72c1c0ff0fac7 to your computer and use it in GitHub Desktop.

Select an option

Save salvatorecapolupo/42fdc07cbff82651dbb72c1c0ff0fac7 to your computer and use it in GitHub Desktop.
# 0. crea un file di testo
mkdir esercitazione123 && cd esercitazione123
# 1. crea un file di testo
echo "CIAO, questo è un test con RSA" > messaggio.txt
# 2. genera chiavi
openssl genpkey -algorithm RSA -out private.pem -aes256
openssl rsa -pubout -in private.pem -out public.pem
# 3. cifrare (funziona solo se il file è piccolo)
openssl pkeyutl -encrypt -inkey public.pem -pubin -in messaggio.txt -out messaggio.rsa
# 4. decifrare
openssl pkeyutl -decrypt -inkey private.pem -in messaggio.rsa -out messaggio_decrypted.txt
# 5. verifica
cat messaggio_decrypted.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment