Using OpenSSL to generate RSA public key

Source: Internet
Author: User
Tags install openssl openssl

RSA public key encryption algorithm is asymmetric algorithm, encryption and decryption use is not the same key, usually has two keys, the public key and the private key, the public key used for encryption, transfer data can use the public key to encrypt the data, the key can be published outside, the private key is used for decryption, When data is received, it can be decrypted with the private key, which is not published externally. Because encryption and decryption of the key is different, so the data in the transmission process security has been greatly safeguarded, the generation of RSA public and private key methods are many, the simplest is the use of OpenSSL, let's see how to use OpenSSL to generate RSA's public and private key bar.

The first nature is to install OpenSSL, Linux installation OpenSSL is very simple, to CentOS for example, yum install OpenSSL on OK, very simple, there is some. Windows can install it, I believe many people will have such a doubt, in fact, Windows can also use OpenSSL, mainly many friends may not find where to download, the following small set to provide a download address, 32-bit and 64-bit, you can download the corresponding version according to the requirements, Small series downloads 32-bit, which can be used normally in XP.

Install complete we open openssl,linux at the command line to enter openssl,windows words after extracting the bin folder, There are openssl.exe files below, double-click to open, windows open when there will be a warning, you can ignore, does not affect our use it to generate public keys and keys. After entering the OpenSSL interface, Linux and Windows are all the same, the following is not described separately.

Generate private key

Generate private key We need to use the OpenSSL genrsa command, and if you want to know how the command is used, you can enter Genrsa--help (some of the command help is really a real-life parameter that displays the command's helpful information, some of which do not exist, The GENRSA does not have a help parameter, but it does not affect the use of the command, so we can see the usage of the command and the parameters that can be attached.

Genrsa: Only input Genrsa, the default generation of 512bit private key, direct output in the terminal.

Genrsa-out PRIVATE_KEY.PEM 1024: Specify output file and generated private key digits, generate 1024bit private key to Private_key.pem file


generate public Key

The public key is built on the basis of the private key, and the command that generates the public key is RSA.

The rsa-in private_key.pem-pubout-out public_key.pem:-in PRIVATE_KEY.PEM represents the input private key, and the-pubout represents the output of a public key,-out Public_ The KEY.PEM represents the output public key to the specified file, where-pubout cannot be omitted, otherwise the private key is output.


At this point, the public and private keys required by the RSA encryption algorithm have been generated. With the help of OpenSSL, we can easily complete the creation of public and private key, of course, the generation is not an end, use is the purpose, then the RSA encryption in the end where, how to use, small series will be in the next article explained in detail, children's shoes, please look forward to it.

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: info-contact@alibabacloud.com 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.