非对称加密算法RSA公钥私钥的模数和指数提取方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fengbingchun/article/details/84973431

生成非对称加密算法RSA公钥、私钥的方法:

1. 通过OpenSSL库生成,可参考  https://github.com/fengbingchun/OpenSSL_Test/blob/master/demo/OpenSSL_Test/funset.cpp  中的Generate_RSA_Key函数;

2. 在Linux下通过命令生成,执行: 

ssh-keygen -t rsa

3. 通过网页  http://web.chacuo.net/netrsakeypair 中的RSA密钥对按钮

通过已有的公钥和私钥提取模数和指数的方法:

1. Linux下可直接通过命令,公钥提取执行:

openssl rsa -pubin -inform PEM -text < pub.key

私钥提取执行:

openssl rsa -inform PEM -text < pri.key

结果如下图:注意:模数需要去除Modulus下的第一个字节即00,公钥和私钥提取的模数和指数都是相同的,只是私钥会有额外的信息输出。

2. 通过网页http://web.chacuo.net/netrsakeypair 中的Rsa公私钥解析按钮,结果如下图,与Linux结果一致:

GitHub: https://github.com/fengbingchun/OpenSSL_Test 

猜你喜欢

转载自blog.csdn.net/fengbingchun/article/details/84973431