Python根据p、q、e参数生成RSA私钥的代码

  • A+

写Crypto题挺好用的,🐎住🐎住。

使用Crypto库需要py2环境,更高版本用的是另外一个库(自行百度,懒):

import math
import sys
from Crypto.PublicKey import RSA

keypair = RSA.generate(1024)
keypair.p = 440140550843727826962832356360132665339
keypair.q = 420226057252427765877741059207519510621
keypair.e = 65537

keypair.n = keypair.p * keypair.q  
Qn = long((keypair.p-1) * (keypair.q-1)) 

i = 1
while (True):
    x = (Qn * i ) + 1
    if (x % keypair.e == 0):
        keypair.d = x / keypair.e  
        break
    i += 1

private = open('private.pem','w') 
private.write(keypair.exportKey()) 
private.close()

//pq可以通过素数分解网站求出

eqqie

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:6   其中:访客  5   博主  1

    • 请输入您的QQ号 请输入您的QQ号 1

      有一说一企鹅真的太强了

      这个评论框快把我闪瞎了 (

      Orz

      • Reverier Reverier 1

        企鹅TQL!!!!!!

        Orz

        • luoqian luoqian 0

          是🐧 awsl

          • Buy CBD Buy CBD 0

            I think that everything composed was very logical.
            But, think on this, what if you were to write a awesome headline?

            I am not suggesting your content is not solid., but what if you added something that grabbed people’s attention? I mean Python根据p、q、e参数生成RSA私钥的代码 | 赤道企鹅的博客 is kinda plain. You ought to glance at Yahoo’s
            front page and note how they create post titles to get people interested.
            You might add a related video or a related pic or two to grab
            readers interested about what you’ve written. In my opinion, it
            would bring your posts a little livelier.

            Also visit my blog – Buy CBD

            • iokjrejbeg iokjrejbeg 0

              Python根据p、q、e参数生成RSA私钥的代码 | 赤道企鹅的博客
              [url=http://www.gov44dnzm9ei520w04g0pg195t2511mns.org/]uiokjrejbeg[/url]
              aiokjrejbeg
              iokjrejbeg http://www.gov44dnzm9ei520w04g0pg195t2511mns.org/