openssl genrsa -out privkey.pem 2048That command outputs the private key in the default PEM format. It is said that "With OpenSSL, the private key contains the public key information as well, so a public key doesn't need to be generated separately." -- sure, but please show me how to extract the public key from it!
It is the openssl rsa command that will do it:
openssl rsa -pubout -in privkey.pem -out pubkey.pem
This post shows how to encrypt/decrypt with the RSA keys. This post gives an example of RSA decryption in C++.