search
Homephp教程php手册MAC下用OPENSSL生成公钥和私钥,macopenssl生成

MAC下用OPENSSL生成公钥和私钥,macopenssl生成

MAC OS自带了OpenSSL,所以不用去编译那一坨跟SHIT一样的源码。直接在命令行里使用OPENSSL就可以。 打开命令行工具,然后输入 openssl打开openssl,接着只要三句命令就可以搞定。第一句命令生成私钥;第二句命令把RSA私钥转换成PKCS8格式,密码为空就行;第三句命令生成公钥。

贴代码 不废话

wangbindeMacBook-Pro:~ wangbin$ openssl

OpenSSL> genrsa -out rsa_private_key.pem   此处如果不加位数 默认是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   转换为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   输出公钥

writing RSA key

OpenSSL>  

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.