Introduction to RSA encryption algorithm here is not copied paste, the following is how to use the command line under the Mac to generate RSA private key and public key.
Using command to generate a 2048-bit private key
OpenSSL genrsa-out Private_key.pem 2048
The current directory will generate a file named Private_key.pem, if opened with a text editor, you will find this:
These things are the key we just generated, this thing can only be placed on the service side, if this thing leaks, the entire RSA encryption link is exposed.
Next we use the private key to generate the public key (command commands must be executed in the directory just below, otherwise you will not find Private_key.pem)
OpenSSL rsa-inform Pem-modulus-noout < Private_key.pem
By executing this command we can print out the public key:
When using the public key, remember to remove the "modulus=" from the front.
Reference Link: Http://www.ohdave.com/rsa
How to generate RSA-encrypted private and public keys under Mac