Esempio n. 1
0
def main():
    while True:
        p = random.randint(65537, 6553700)
        if miller_rabin(p):
            break
    while True:
        q = random.randint(65537, 6553700)
        if miller_rabin(q):
            break
    print(p, q)
    n = p * q

    ### 3b. refer to https://crypto.stackexchange.com/questions/3110/impacts-of-not-using-rsa-exponent-of-65537
    e = 65537
    ## for security, padding seems to be more important than the size of public exponent?
    ## we can test the algorithm with small e if it takes too long time to compute.
    e_test = 3
Esempio n. 2
0
def main():
    """ example of the prime function and custom tests """
    # Demo of the Primary testing functions
    print(is_prime(7))
    print(p.fermat(7))
    print(p.miller_rabin(7))

    # Demo of the Prime generating functions
    print(p.generate_primes(7))
    print(p.find_primes(2, 7, p.fermat))

    # Demo of the custom_test functions
    print(ut.custom_test(p.is_prime))

    # Demo of Graphical Prime functions
    sacks_plot()
    ulam_plot()
Esempio n. 3
0
def checkPrime():
    count = 0
    while count < 4:
        num = str(random.randint(1000000000, 2000000000))
        last = num[len(num) - 1]
        if int(last) != 0 and int(last) != 5 and int(last) % 2 != 0:
            num = int(num)

            prime = miller_rabin(num, 40)

            if prime:
                # print(num)
                # print("YES")
                numList.append(num)
                count += 1
            # else:
            #   print("NO")

            # count += 1
            if count == 2:
                break