You will need a better algorithm than the Sieve of Eratosthenes if you want to generate the kinds of large prime numbers needed for the RSA algorithm. Here's an implementation of the Miller-Rabin primality checker for Python:
def isPrime(n):
def isSpsp(n, a):
d, s = n - 1, 0
while d % 2 == 0: d, s = d / 2, s + 1
t = pow(a, d, n)
if t == 1: return True
while s > 0:
if t == n - 1: return True
t, s = (t * t) % n, s - 1
return False
ps = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
if n in ps: return True
for p in ps:
if not isSpsp(n, p): return False
return True
If you're interested in programming with prime numbers, I modestly recommend this essay at my blog; you might also look at some of the other pages at my blog, including this one on generating RSA semi-primes.