python实现公钥加解密RSA算法_python rsa公钥解密(1)

⭐本专栏主要用python实现密码学中的常用经典算法,例如Vigenere、3DES、RSA、ElGamal、Diffie-Hellman、RSA签名、ElGamal签名、HMAC、哈希算法、列移位、AES等等。
🔥文章和代码已归档至【Github仓库:cryptography-codebase】,需要的朋友们自取。或者公众号【AIShareLab】回复 密码学 也可获取。

Program : Textbook RSA (on group)

In this part, you are required to implement the textbook RSA algorithm from scratch. It contains the following three procedures, KeyGen, Encrypt, and Decrypt.

  • KeyGen

    • Return the private key

    (

    N

    ,

    d

    )

    (N,d)

    (N,d) and the corresponding public key

    (

    N

    ,

    e

    )

    (N,e)

    (N,e). The prime number

    p

    p

    p and

    q

    q

    q should be approximately 512 bits and therefore the RSA modulus number

    N

    N

    N should be approximately 1024 bits. Note that finding an encryption exponent

    e

    e

    e might be time-consuming.

  • Encrypt

    • Given a plaintext message

    m

    Z

    N

    m \in \mathbb{Z}_N

    m∈ZN​ and a public key

    (

    N

    ,

    e

    )

    (N,e)

    (N,e), return the encrypted message

    c

    c

    c.

  • Decrypt

    • Given a ciphertext message

    c

    Z

    N

    c \in \mathbb{Z}_N

    c∈ZN​ and a private key

    (

    N

    ,

    d

    )

    (N,d)

    (N,d), return the decrypted message

    m

    m^\prime

    m′.

Your program does the following:

  • Generate a textbook RSA key pair. You may use the Miller-Rabin Test algorithm to determine whether an integer is prime. Print the private key and the public key as multiple decimal strings.
  • Read a decimal string representing a plaintext message

m

m

m. Raise an exception if

m

m

m is invalid.

  • Encrypt the message

m

m

m. Print the encrypted message

c

c

c as a decimal string.

  • Decrypt the encrypted message

c

c

c. Print the decrypted message

m

现在能在网上找到很多很多的学习资源,有免费的也有收费的,当我拿到1套比较全的学习资源之前,我并没着急去看第1节,我而是去审视这套资源是否值得学习,有时候也会去问一些学长的意见,如果可以之后,我会对这套学习资源做1个学习计划,我的学习计划主要包括规划图和学习进度表。

分享给大家这份我薅到的免费视频资料,质量还不错,大家可以跟着学习

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里无偿获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 29
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值