0


使用Openssl的RSA算法生成公私钥对

openssl的安装参考这里:openssl的安装指导
非对称加密算法:RSA1024 /2048 /3072 /4096

在需要放置公私钥对所在的文件夹下,按住shift键点击右键,选择“在此处打开命令窗口”,可以打开cmd窗口。不会用快捷键的可以在命令行一步步cd跳转到文件夹也是可以的。
1、生成RSA3072私钥
在命令行中直接输入以下命令即可得到私钥的privatekey.txt文件。

openssl genrsa -out privatekey.txt 3072

2、根据私钥生成公钥
可以使用以下命令生成私钥对应的公钥。

openssl rsa -in privatekey.txt -out publickey.txt -pubout

如下例子RSA3072公私钥对:

-----BEGIN PRIVATE KEY-----
MIIG/QIBADANBgkqhkiG9w0BAQEFAASCBucwggbjAgEAAoIBgQCDkAQzFvuJyxPc
2m3JIzH+pATKw7jUgQlMWHwQSIHoRlye5EHbx+zR3DhIY/ZmYoUJwHvVz9/WLuhZ
3oE3FxWZSFx6miuzpfttd/wJ8XHsOzZOZTDrsTm8cuVBlWsopxjXLpfKhEyPP8xG
6JCcXoixCDWnCYWvNKxA+r0D7Yj1NlMVeUfv0QUGx/rXSGleOeD8Z7991owdN9f4
86SrFCTs5aBMy82/QNSvVlKsyUileUGV8a+SwGrP4uVXf0QOUiJer4yjVOPMqupD
UCm/WrcVVVRaXnVlt3QAM1PQKrSbLJGf6f9qjt3L9WRDO4pIvoIdgZnTIl1hveD9
QbY/34Eptzkd4tRBfGdrUTrPz4HSA8ExqCKqxUfwjNwRhQUd8CgaWcIaCkP3MESp
kT7R68G1lyd5SmCSvvvWBeKjKI66SkAn7u9M/WRnUiQgVQfpN6wsev7vVm8RorMU
qm8rnhfETQXuTUFar7UxjFTadBwgiInvpbkoA3yH+nS64LBw7EsCAwEAAQKCAYA6
cWp8K5R4BL+BF4M3m6vk24XJcSKVO/Eeehw6u4sB3OfeKbXb5Tcdjr9t4QIfP1qs
F1arh5l+sv3ClmY+S8HrgsqaKAyL1IsZePh8jkY2U6NvNeKCgQsN3NhcxvyAZaJS
TL9fVmAQLp4XTc6XuCLu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HfAoGlnCGgpD9zBEqZE+0evB
tZcneUpgkr771gXioyiOukpAJ+7vTP1kZ1IkIFUH6TesLHr+71ZvEaKzFKpvK54X
xE0F7k1BWq+1MYxU2nQcIIiJ76W5KAN8h/p0uuCwcOxLAgMBAAE=
-----END PUBLIC KEY-----

标签: 网络安全 batch bash

本文转载自: https://blog.csdn.net/import_new/article/details/127253990
版权归原作者 兄弟李德胜 所有, 如有侵权,请联系我们删除。

“使用Openssl的RSA算法生成公私钥对”的评论:

还没有评论