Last active
May 10, 2023 09:13
-
-
Save Aurora12/4c20ef4e1aa12aab2a257786b1669d37 to your computer and use it in GitHub Desktop.
Basic openssl encrypt-decrypt with RSA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a private key | |
# Note: RSA can only encrypt messages that have fewer bits than the key. | |
openssl genrsa -des3 -out ./private4096.pem 4096 | |
# Export public key | |
openssl rsa -in ./private4096.pem -outform PEM -pubout -out ./public4096.pem | |
# Encrypt | |
openssl rsautl -encrypt -inkey ./public4096.pem -pubin -out ./ciphertext.$(date +'%Y-%m-%d_%H-%M-%S') -in ./plaintext.file | |
#Decrypt | |
openssl rsautl -decrypt -inkey ./private4096.pem -in ./ciphertext.file > plaintext.$(date +'%Y-%m-%d_%H-%M-%S') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment