SSL Encryption/Decryption – Quick Cheat Sheet

Print Friendly, PDF & Email
## Generate Private Key
openssl genrsa -out private-key.pem 8196
 
## Generate Public Key using above Private Key
openssl rsa -in private-key.pem -out public-key.pem -outform PEM -pubout
 
## Encrypt a file named file.txt to a file named file.txt.encrypted
openssl rsautl -encrypt -inkey public-key.pem -pubin -in file.txt -out file.txt.encrypted
 
## Dectrypt an encrypted file named file.txt.encrypted to a file named file.txt.decrypted
openssl rsautl -decrypt -inkey private-key.pem -in file.txt.encrypted -out file.txt.decrypted

Leave a Reply

Your email address will not be published. Required fields are marked *