Home  >  Article  >  Backend Development  >  Use OPENSSL to generate public and private keys under MAC, macopenssl generation_PHP tutorial

Use OPENSSL to generate public and private keys under MAC, macopenssl generation_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:02:001065browse

Use OPENSSL to generate public and private keys under MAC, and macopenssl generates

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.

Post the code, no nonsense

wangbindeMacBook-Pro:~ wangbin$ openssl

OpenSSL> genrsa -out rsa_private_key.pem If you don’t add digits 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-----

MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANRjCZcxJGyGMrbz

4Xyg8YHyeB/fvChwmAY0uRXnNbPQ1L53RFQUGlO/ZM16o3Bxx5ulGrl WqkBMhpX

uZazSPcng5VZJxITiNQ8gZms9ogus8OZXBopSXrCfO1evlmfEHt4hG0vjQ2b6xd3

KXDJ/Tr4hisiZdAi6reB3kVHhv7hAgMBAAECgYBYQ6BkuQOOJmdFKS14gdpcSswp

Uu37UG dhKO2upPS2uLPFPnMh145l7zouCLcRCzUPlVQ6XX77odH81Upj/CuI/t0

CwnSOBecP4QsfNcihpkJeezjTcgxCuwHYZ2EyeOp/SZB9rLK6OhJoA3H xi1i2i2

TZzJioTmEVPrLF/UAQJBAPlK2VU9msADCook5rRbj57ghZdAYUrBPuoaaoAmpYZF

UhN5SRkZkDEhMI2IhGXVwqI9ilgSr5uT2Q4wOGaPFlECQQDaGfrHg2CsuUsAhd48

bzaxoRYz08l2UTPOyZTTV7C3 e8S2n XLVsX 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>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1087141.htmlTechArticleUse OPENSSL to generate public and private keys under MAC, macopenssl generates MAC OS comes with OpenSSL, so there is no need to compile it That piece of source code is the same as SHIT. Just use OPENSSL directly from the command line. Hit...
Statement:
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