I'm trying to make a code to find two prime numbers, that I can calculate the multiplication of p and q.
I wanted to use thereby the Algorism of eratosthenes (the Algorism to find Primnumber) so my code would look like this:
find_primenumber=2**1024
# Algorism of eratosthenes (Primzahlen finden )
a = [False,False] + [True]*(find_primenumber-1)
primes=[]
for i in range(2,find_primenumber+1):
if a[i]:
primes.append(i)
for j in range(2*i, find_primenumber+1, i):
a[j] = False
# according to the p,q, the decrypted messages can be different.
p= primes[-1]
q= primes[-2]
# öffentliche Schlüssel public key (n,g)
n = p*q
This Code works very well, if I set the range of numbers (find_primenumber in the code), very small like 1000000. But I have to find in the longer range such as at least 2^1024. but when I set the length 2**1024 (2^1024). The Error comes out like this:
Do you have any idea, how I can fix this problem?
Thank you!