Use generate RSA public key and key on Mac

Source: Internet
Author: User
Tags install openssl openssl rsa

About RSA encryption and decryption problem, nothing to get a bit, first the main process to save, for Exchange or later use.

First make sure that you have the OpenSSL installed on your PC, and that your Mac system will install automatically after installation! How to install?? ..... Please Baidu ...

The installation commands are as follows:

sudo apt-get install OpenSSL

Create a folder anywhere in your location to save your public key and key,

Open the Terminal TERMINAL,CD command to enter the folder you created, such as Create a new "RSA Public Key" folder on the desktop, enter this directory, command

Next we start generating the public key and the key:

1. Generate the RSA private key:

Enter the following command in terminal (the command generates a 1024-bit private key):

OpenSSL genrsa-out Rsa_private_key.pem 1024

After carriage return as shown:

At this point you can see the Rsa_private_key.pem file under the RSA public key private keys folder.

2. Convert RSA private key to PKCS8 format

OpenSSL pkcs8-topk8-inform pem-in rsa_private_key.pem-outform pem–nocrypt

Enter the password and confirm the password after the return, the following will be displayed after the return:

The result of a successful life is the private key in the PKCS8 format.

3. Generate the Public key:

OpenSSL rsa-in rsa_private_key.pem-out rsa_public_key.pem-pubout

After carriage return

At this point, we can see a file named Rsa_public_key.pem, which is the public key.

Here, there will be two files under the folder "RSA public Key": Rsa_private_key.pem and Rsa_public_key.pem, which is the public key and private key we need!

Use generate RSA public key and key on Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.