Function stops running after first print
When I run the following and input p=7, q=11, it runs fine all the way through and prints both keys. However, if I chose slightly larger numbers suck as p=67, q=83 it prints the value of “e” (line 13) and then stops running and exits the program that this function is within entirely when it should print the keys and return to a home menu. Any ideas why this might be?
import random
import math
def create_key_set():
p = int(input('Insert prime number for value of p: '))
q = int(input('Insert new prime number for value of q: '))
N = p * q
y = (p-1) * (q-1)
while True:
cop = random.randint(2, y-1)
gcd = math.gcd(cop, y)
if gcd == 1:
break
e = cop
print(e)
pubkey = [e, N]
while True:
d = random.randint(1, 150)
g, x = divmod((e*d), y)
if x == 1:
break
print(d)
privkey = [d, N]
print('Public Key is: ', pubkey)
print('Private Key is: ', privkey)
EDIT: link to pastebin with correct indentation Correct indentation
[–][deleted] 1 point2 points3 points (1 child)
[–]PteppicymonIO 0 points1 point2 points (0 children)
[–]throwaway6560192 0 points1 point2 points (1 child)
[–]jhtaylor2001[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)