mac 上生成RSA公钥和私钥pkcs8格式

PKCS8转成PKCS#1可以在线RSA PKCS#1 转 PKCS8格式私钥
1、打开Terminal--cd 到指定文件夹makeRSA

openssl
mac 上生成RSA公钥和私钥pkcs8格式_第1张图片
Snip20170824_2.png

出现这种格式,
2、在OpenSSL> 后面敲以下命令行
// 第一句命令:生成私钥。

 genrsa -out rsa_private_key.pem 2048 

接下来Terminal显示内容如下:
Generating RSA private key, 2048 bit long modulus
...............+++
..............................................+++
e is 65537 (0x10001)

3、OpenSSL>后面敲以下命令
第二句命令:把RSA私钥转换成PKCS8格式。提示输入密码,密码为空(直接回车)就行;

pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM –no crypt

4、Terminal显示如下:
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIE6TAbBgkqhkiG9w0BBQMwDgQIiQ4PFYMqa7ECAggABIIEyARDwR3lbjFQYGmy
ASuI2D8LJXOtQDf/BIfFFln6d9UgppOEWlKIrp1ms6BF0nP76mtBiOpsk5QjPhTK
U4snDLT/w/hTc2OBPe66poOtzlVPtKLacfTH1pMzHUWcVz4cmCI+SAMTRkdQ1EG+
UtmdlISxoHqFIuiP4GsuyItVLrqvYMEN+4rMkcO6HgKTInvAVogp05QzJCSOVKCX
6C9Jpgdy+la9rIqteueioYofmgFojZGQtuCh03BgFBD5cHjMWNZ9X9vmxq/ih0ib
NhUptlvwQeaA2OO0pDhOM613b8osGFxvhb14KjMCQdfaYAu9fYw2rFNbZG4Q6BBu
7j+iheHiUdqA/2K9IjTf8kcJGYbQvAlz8GdL/psosk7irBndHEOOZTLgY4xU6t71
Vxwyf9WHbTuuY+MZbzMdo02lKTcznpiT0wdEu+gD5juz5wTVKyZ2HIoT+47Vte6Z
J16X9X1jw3KlIwDl/vFTEBGS1lfn8kMxyuGbomEMlF+If8MXvtY3mfBO5FHSy271
YVRCemxygsUpnMRgRjBdeCAefO8e+vEI2Rh/goCwkq+QmtNnhxMMXdiSn/Sx2KiZ
vLu+ua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以下命令// 第三句命令生成公钥。

rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem

Terminal显示:
writing RSA key

6 生成的文件,一个私钥,一个公钥

mac 上生成RSA公钥和私钥pkcs8格式_第2张图片
Snip20170313_10.png

你可能感兴趣的:(mac 上生成RSA公钥和私钥pkcs8格式)