Your cart is currently empty!
OpenSSL: Public-Private Key Encryption
Generate private key
First, you need a private key to generate a public key.
openssl genrsa -out privatekey.pem 2048
Generate public key
openssl rsa -in privatekey.pem -pubout -out publickey.pem
Encrypt using public key
echo "hello" > hello.txt
openssl pkeyutl -encrypt -inkey publickey.pem -pubin -in hello.txt -out hello.txt.enc
Decrypt using private key
openssl pkeysutl -decrypt -inkey private.pem -in hello.txt.enc -out hello.txt
Leave a Reply