Example #1
0
def main7():
    set_random_seed(0)
    p = next_prime(randrange(2**96))
    q = next_prime(randrange(2**97))
    n = p * q
    print(p, q, n)
    print(qsieve(n))
Example #2
0
def crack_given_decrypt(n, m):
    n = Integer(n)
    m = Integer(m)

    while True:
        if is_odd(m):
            break
        divide_out = True
        for _ in range(5):
            a = randrange(1, n)
            if gcd(a, n) == 1:
                if Mod(a, n) ** (m // 2) != 1:
                    divide_out = False
                    break
        if divide_out:
            m //= 2
        else:
            break

    while True:
        a = randrange(1, n)
        g = gcd(lift(Mod(a, n) ** (m // 2)) - 1, n)
        if g != 1 and g != n:
            return g