密码学学习笔记之连分数 | Van1sh的小屋 (jayxv.github.io) 勒让德定理,满足定理可用连分数近似 c = N1 = N2 = e = cf = continued_fraction(Integer(N1) / Integer(N2))i = 1while 1: q1 = cf.numerator(i) q2 = cf.denominator(i) if N1 % q1 == 0 and q1 != 1: print(q1) p1 = N1 // q1 d = gmpy2.invert(e,(p1-1)*(q1-1)) m = pow(c,d,N1) flag = long_to_bytes(int(m)) if b"ISCTF" in flag: print(flag) break i += 1