Home > Backend Development > PHP Tutorial > Use OPENSSL to generate public and private keys under MAC

Use OPENSSL to generate public and private keys under MAC

WBOY
Release: 2016-07-29 09:08:15
Original
1536 people have browsed it

MAC OS comes with OpenSSL, so there is no need to compile the same source code as SHIT. Just use OPENSSL directly from the command line.

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

No nonsense when posting code

wangbindeMacBook-Pro:~ wangbin$ openssl

OpenSSL> genrsa -out rsa_private_key.pem If no digits are added here, the default 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 Convert to pkcs8

-----BEGIN PRIVATE KEY-----

MIICdgIBADANBg kqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANRjCZcxJGyGMrbz H4xyg8yhyeb /vchwmay0urxnnbpq1L53rfquglo/ZM16O3BXX5ULGRL+WQKBMHPXSPCNG5VZJXITINQ8GZMS9OPSXRCFO1EVLMFEHT4HG0V jq2b6xd3dkxdj/Tr4hisizdai6reb3kvhhv7hagmbaaecgybybyq6BKUQOOJMDFKS14GDPCSSWP

UU37ug+ DH81upJ/CUI/T0

cwnsobeCP4QSFNCIHPKJEZCGXCUWHYZEYEOP/SZB9RLK6OHJOA3H+xi1i2i2i2

tzzjiotmevprf/UAQJBAPLK2VU9MSADCOOK5RRBRBRBRBRBRBRRB J57GHzDayurbPUOAOAMPYZF

UHN5SRKZKZKDEHMI2IHGXVWQI9ILGSR5UT2Q4WOGAPFLECQDAGFRHG2CSUSAHD48

BZAXOL2UTPOYZ7C3+E8S2N+X LVSX+CKUPT8SFXJVN5MVQ8H6XTEMOSW0

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

L/lLk6w9cMWWJDYWloZDoQq7y3HhAkAGuO5F4ALG0B9DsNycuEDTUMfCaTC4eOBD

62qu6PEFeqqnxhxQqJE6N+fsPvunfD6QbQ63hRMhiGYCtaUKXbxBAkEAxDpbFB3b

MKYjVoxolvIjoTiNY1e78bk4vokr4htlQ8Cubg1VWUKOGELHBG24JpRGS3KRsObk

5pYoW+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 introduces the use of OPENSSL to generate public keys and private keys under MAC, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template