实验吧密码学:RSAROLL
原题:
{920139713,19} 704796792 752211152 274704164 18414022 368270835 483295235 263072905 459788476 483295235 459788476 663551792 475206804 459788476 428313374 475206804 459788476 425392137 704796792 458265677 341524652 483295235 534149509 425392137 428313374 425392137 341524652 458265677 263072905 483295235 828509797 341524652 425392137 475206804 428313374 483295235 475206804 459788476 306220148
题目给出了n和e,首先分解质因数
可以在线分解:http://www.atool.org/quality_factor.php
接下来就是通过程序实现解密:
1 #-*- coding:utf-8 -*- 2 #博客园 hell0_w 3 4 import gmpy2 5 import libnum 6 7 p = 18443 8 q = 49891 9 e = 19 10 list = [] 11 list1 = [] 12 f = open('rsa.txt','rb') 13 for line in f.readlines(): 14 line = line.strip('\r\n') 15 list.append(line) 16 17 18 n = p * q 19 l = (p-1) * (q-1) 20 21 d = gmpy2.invert(e,l) 22 for i in range(len(list)): 23 m = pow(int(list[i]),d,n) 24 list1.append(libnum.n2s(m)) 25 26 print ''.join(list1)
。。。