RSA求解明文,安利函数pow()

本文介绍了一种使用RSATool和Python pow()函数进行RSA解密的方法。首先通过工具获取公钥n、e、p、q及私钥d,然后利用Python的pow()函数求解明文。具体步骤包括下载并配置RSATool,使用工具分解n获得p、q,计算私钥d,最后通过pow()函数计算出明文。
该文章已生成可运行项目,

1.先安利一个超好用的RSA解密工具

点击下载RSA Tool

打开RSA Tool
1.Number Base 设置为十进制
2.注意:Public Exponent这里要使用16进制的数,如果公钥e=17的话,就应该填入十六进制的11
3.给出p,q,e的话直接填入,再点击Calc.D,获得d
4.给出的是n和e的话,输入n和e,点击Factor N(分解),得到p,q,再重复第3步就能得到d了
在这里插入图片描述

这是一道求明文的RSA题目

在这里插入图片描述

2.获取公钥n,e,p,q

用上面给的工具就能得到了

3.获取私钥d

同上

4.解出明文

这里可以用Python里面一个非常有用的内置函数pow()

pow(x,y,z) 这个是表示x 的y 次幂后除以z的余数

>>> pow(3,2,5)

5

所以pow()可以进行“快速求幂取模运算”

#在python3.x中测试的
p = 9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483
q = 11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407
n = p*q
#密文
C = 83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034

d = 56632047571190660567520341028861194862411428416862507034762587229995138605649836960220619903456392752115943299335385163216233744624623848874235303309636393446736347238627793022725260986466957974753004129210680401432377444984195145009801967391196615524488853620232925992387563270746297909112117451398527453977

#求明文
M = pow(C,d,n)
print(M)

得到明文为:
5577446633554466577768879988

本文章已经生成可运行项目
RSA-Tool 2 Copyright ?2000-2002 by tE! [TMG] Introduction Please read this text carefully. This utility has been made for those who want to use the RSA public key algorithm in their own programs. It offers creation of strong keypairs and a nice integer factorization feature which makes use of several differnt factoring methods including the MPQS. It's possible to factor integers +256 bits in size but please keep in mind that this can take a *lot* of memory and time ! Thus it's not recommended to try factoring bigger numbers on slow machines with a few MB of physical Memory. Don't even think of trying to factor 512 bit numbers for example.. RSA-Tool 2 Features: - Secure keypair generation - Key test dialog - Support of multiple number bases - Auto base-conversion on select - Support of numbers up to 4096 Bits 1. About RSA RSA is a Public Key Cryptosystem developed in 1977 by Ronald Rivest, Adi Shamir and Leonard Adleman. Since 09-20-2000 the U.S. Patent #4,405,829 on this Algorithm EXPIRED! That means that the Algorithm is Public Domain now and can be used by everyone for free, even in commercial software. 2. Parameters P = 1st large prime number Q = 2nd large prime number (sizes of P and Q should not differ too much!) E = Public Exponent (a random number which must fulfil: GCD(E, (P-1)*(Q-1))==1) N = Public Modulus, the product of P and Q: N=P*Q D = Private Exponent: D=E^(-1) mod ((P-1)*(Q-1)) Parameters N and E are public whereas D is -private- and must NEVER be published! P and Q are not longer needed after keygeneration and should be destroyed. To obtain D from the public key (N, E) one needs to try splitting N in its both prime factors P and Q. For a large Modulus N (512 bit and more) with carefully chosen primefactors P and Q this is a very difficult problem. All the security of the RSA encryption scheme relies on that integer factorization problem (tough there's no mathematical proof for it). To fin
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值