Use OPENSSL to generate public and private keys in MAC

Source: Internet
Author: User
Tags modulus
: This article describes how to generate a public key and a private key using OPENSSL in MAC. For more information about PHP tutorials, see. Mac OS comes with OpenSSL, so you don't need to compile the same source code as SHIT. Use OPENSSL directly in the command line.

Open the command line tool, enter openssl to open openssl, and then you can do it with just three commands. The first command generates the private key. the second command converts the RSA private key to the PKCS8 format. the password is empty. The third command generates the public key.

Post code without nonsense

WangbindeMacBook-Pro :~ Wangbin $ openssl

OpenSSL> genrsa-out rsa_private_key.pem. If no bits are added, the default value is 512.

Generating RSA private key, 512 bit long modulus

... ++

. ++

E is 65537 (0x10001)

OpenSSL> genrsa-out rsa_private_key.pem 1024

Generating RSA private key, 1024 bit long modulus

... ++

...

E is 65537 (0x10001)

OpenSSL> pkcs8-topk8-inform PEM-in rsa_private_key.pem-outform PEM-nocrypt to pkcs8

----- Begin private key -----

Miicdgibadanbgkqhkig9w0baqefaascamawggjcageaaogban#czcxjgygmrbz

4Xyg8YHyeB/fvChwmAY0uRXnNbPQ1L53RFQUGlO/ZM16o3Bxx5ulGrl + WqkBMhpX

Bytes

KXDJ/Tr4hisiZdAi6reB3kVHhv7hAgMBAAECgYBYQ6BkuQOOJmdFKS14gdpcSswp

Uu37UG + dhKO2upPS2uLPFPnMh145l7zouCLcRCzUPlVQ6XX77odH81Upj/CuI/t0

CwnSOBecP4QsfNcihpkJeezjTcgxCuwHYZ2EyeOp/SZB9rLK6OhJoA3H + xi1i2i2

TZzJioTmEVPrLF/UAQJBAPlK2VU9msADCook5rRbj57ghZdAYUrBPuoaaoAmpYZF

Bytes

BzaxoRYz08l2UTPOyZTTV7C3 + e8S2n + XLVsX + CkUpT8sFxJVn5MVQ8H6XTemOsW0

T + uRAkAXJnJETjI + vomOBps + CHqv4F3Hi/z8 + jEjgEx/lhcs/ub + U/cL06nmRhTC

L/snapshot

62qu6PEFeqqnxhxQqJE6N + fsPvunfD6QbQ63hRMhiGYCtaUKXbxBAkEAxDpbFB3b

MKYjVoxolvIjoTiNY1e78bk4vokr4htlQ8Cubg1VWUKOGELHBG24JpRGS3KRsObk

5 pYoW + DHTbftYw =

----- End private key -----

OpenSSL> rsa-in rsa_private_key.pem-pubout-out rsa_public_key.pem output public key

Writing RSA key

OpenSSL>

The above describes how to use OPENSSL to generate a public key and a private key in MAC, including some content. I hope my friends who are interested in the PHP Tutorial will be helpful.

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.