美文网首页
RSA公钥生成步骤

RSA公钥生成步骤

作者: _冷忆 | 来源:发表于2016-09-20 11:33 被阅读661次

    1.打开终端,输入openssl命令

    mac-mini:~ ice$ openssl
    OpenSSL>
    

    2.生成私钥

    OpenSSL> genrsa -out rsa_private_key.pem 2048
    Generating RSA private key, 2048 bit long modulus
    .......................................................................................+++
    ...............................+++
    e is 65537 (0x10001)
    

    3.把RSA私钥转换成PKCS8格式。提示输入密码,密码为空(直接回车)就行

    OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM –nocrypt
    Enter Encryption Password:
    Verifying - Enter Encryption Password:
    -----BEGIN ENCRYPTED PRIVATE KEY-----
    MIIE6TAbBgkqhkiG9w0BBQMwDgQImJVGpBG0hagCAggABIIEyD4yTY0eYGzpAePW
    VGA7DF5vaoiiAijyLx6aYUZxMHYecBGguJJVjUX2DaWXMRjXZ5Zd86ddZNiJtq9/
    /uS0cO84XP8h9No7BY8Tt8wVC/6xdjtussmaaaArbNlOtufCqN/SgQWCMRgFhbcz
    FA16/vFAFe0ajocDuE/hPgYJJlD7BzSpxdyLuHJUfeTsc3O4nYk5dB5BWcH7fgLH
    X61yOjQDoG0EkM5t/vmSi2iISdeV+7FOHrYR+WoSQeTT9CmVhOLxwxxO0iNptIHc
    6PDmtSOGa/egl/fbtB/vC33CGYWyvAHPDgTDF+YeIDCEO2vOG+jw9HAOCgPhTEry
    jEvxnhqLzI/OJnRTVOChIDNS6kb/htOYm91sYpA83mzaY3r1L3fgm4g3g1UaWk6J
    OKPzobIxT4rVsTSXFiDV7CPBstw5Z5/53TMaI+lYVR2cLrhKwN4k0aCNr0a/WI4y
    d9gJFQTBQxLa6NhcyZjDanhF/ZznI4z0G1/RMkfG8n+draRRG7frxxVBA8D95CCI
    MeAIOhdPAUA0oeci2/3ap6kgaTLcQH3ECwvAUp1jE3kz8pYpvWbqFOu6w6S4NDIm
    cZ+BW+xwo2TH1WCS6TbgUD7843+GexRkO5XAzeftxncOSSBJp//UlAoJQeWYcMW+
    cd6bkKi/UU9Hsk6UuXd51TAqDVgC/ZSrDQlcbAYWKofv3JBk360/A53QxrqzfgKv
    L6Jwek2k+r6AD8dVpg5fxfRsempqLUtpjf/5EmsSAJAVgLpwNtluLWpiAwVBzP7u
    LFhxt59rIKaIGh1Evi76KDVWh6jodDn/JER7EkN0t1kREWAdjhf++H1mWTqk4K1T
    8UADuT0kr0f4AKXqpjSzGYX0bI+Yxb4cODr8FnVquvplt6+fn2c0dK3Zv/r5hfQ0
    8s1fvLWc4QzdiONchm2o2hou+fRmIdefTJuTFnroKb/izUWJ82XiXh2aWojnKzlt
    7Mlx7bjB+Vx3qRd3PIrBGUw3NCUabRGAVxurs6L4pyF/PAhyEHZ8AOHITFcBI4ZM
    +QdvaWUHBopSzPHJHstW/VZ0zJfmHR2+fBGVBeFFM4jx4yx6ZgU91Y96o1Yq1gtj
    eY/jSljfYMPNWh3t817EyhrYlIO4/BjI2KHF/qs+4YQxLBhJNKx4X1R+QPSM21Q9
    IWC2izkUxtxjcPu2Hq3HbKdSJSAphpA+5hnAs9eiEpUDn/hvwHwlp1xG1bSiXY7m
    FdxGDJ+jno1kCxh9WOArX6B5AeumRWlXIg7E42W68s7gaAQB4vtw+6fXIYBnq4Lt
    nMwdsptiEjG8NysB+YaiJ8oixKN+rl8CrXWvmAzDFyxiV/L8KVGPcB5BE5hpdWiJ
    FPmM59FRJlwWTiZnDsRsv1YYxBrt0wlZgFjHm+LW1pDfmfRHQkRSlh+BxYc9v9bK
    DTvkmUP1zRBybj8vXyWdhYaPig0R9KjDSlO8K/vXEeow+4UJ729CcZ3Pk+VObpZQ
    d4ROsZh2FpliCOC5xMA8u2cAMuTSicLfEdFxVbZgtuvOH3x5fVIzxxrFoW4N1SNy
    ukBHcJyjo+cJsxq2KpDm39cpWSRgr2MMfud5T4FPW7WmoR0l+4fv2tjTeBIHI9YT
    mZrEj++2rqwnKZ6YcA==
    -----END ENCRYPTED PRIVATE KEY-----
    

    4.生成公钥

    OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
    writing RSA key
    OpenSSL> 
    

    5.最后秘钥存放在 Macintosh HD ->用户->(你自己的电脑名称) 下面有两个文件
    ras_private_key.pem was_public_key.pem

    相关文章

      网友评论

          本文标题:RSA公钥生成步骤

          本文链接:https://www.haomeiwen.com/subject/xbfoettx.html