RSA求解

已知p,q,e求d BUUCTFL:RSA

from Crypto.Util import *
import gmpy2
p=473398607161
q=4511491
e=17
phi=(p-1)*(q-1)
print type(p*q) #长整型数据,自己的求模逆的脚本截断出错
print gmpy2.invert(e,phi)

正常RSA求解

from Crypto.Util.number import *
import gmpy2

p =9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483
q =11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407
e =65537
c =83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
n=p*q
#print d
def decode():
    print pow(c,d,n)
    m=long_to_bytes(pow(c,d,n))
    #print type(m)
decode()
posted @ 2021-08-31 20:22  zer0_1s  阅读(49)  评论(0编辑  收藏  举报