Public and private can be generated using the OpenSSL tool.
In a Windows environment, you can download the OpenSSL tool (http://www.openssl.org/related/binaries.html) yourself.
In a Linux environment, you can install the OpenSSL toolkit (in Ubuntu, for example, execute sudo apt-get install OpenSSL).
Under Windows environment, open the Openssl.exe under the OpenSSL installation directory bin file. In a Linux environment, you run OpenSSL directly in the terminal.
1) Generate RSA private key:
Genrsa-out RSA_PRIVATE_KEY.PEM 1024
The command generates a 1024-bit private key, which generates a successful interface as follows:
At this point we can see the Rsa_private_key.pem file under the current path.
2) Convert RSA private key to PKCS8 format
Input command Pkcs8-topk8-inform pem-in rsa_private_key.pem-outform pem–nocrypt, and enter
The result of a successful birth is a private key in the PKCS8 format, such as:
3) Generate RSA public key
Enter command rsa-in rsa_private_key.pem-pubout-out Rsa_public_key.pem, and enter,
Get the results of a successful build, such as:
At this point, we can see a file named Rsa_public_key.pem, open it, you can see-----begin public Key-----start,
-----End of the public key-----The string with no newline, this is the key.
How to use OpenSSL to generate RSA public and private key pairs