Last active
February 9, 2021 02:20
-
-
Save garystafford/0e22315039f2bf12a86c871a1a6629c8 to your computer and use it in GitHub Desktop.
This file contains 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
# public-key cryptography demo for Mac or Linux | |
# create the private key - require a pass phrase | |
# openssl genrsa -aes256 -out sec-cert.pem 2048 | |
# create the private key - no pass phrase required | |
openssl genrsa -out sec-cert.pem 2048 | |
# create public key (PEM) | |
openssl rsa -in sec-cert.pem -outform PEM -pubout -out sec-cert.pub.pem | |
echo "This is a message that will be encrypted with my public key..." >> myMessage.txt | |
# encrypt the text file | |
openssl rsautl -encrypt -pubin -inkey sec-cert.pub.pem -oaep -in myMessage.txt -out myEncryptedMessage.txt | |
cat myEncryptedMessage.txt | |
# decrypt the text file | |
openssl rsautl -decrypt -inkey sec-cert.pem -oaep -in myEncryptedMessage.txt -out myDecryptedMessage.txt | |
cat myDecryptedMessage.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment