Page 1 of 1

GENERATE PRIME NUMBERS

Posted: Fri Sep 21, 2007 3:39 am
by devendra-m
I am trying to implement RSA in PHP. But I am not being able to generate 128bit prime numbers. Do you how to generate 128 bit prime numbers.

Posted: Fri Sep 21, 2007 5:27 pm
by Ambush Commander
Without a solid mathematical foundation, I would strongly advise against attempting to implement RSA in PHP due to the high probability of implementation errors. Try: http://pear.php.net/package/Crypt_RSA

Posted: Fri Sep 21, 2007 9:29 pm
by Begby
Writing your subject all in caps is not going to get more people to try and answer your question.


I assume you are trying to generate a 256bit key. To generate a 128 bit prime you need to choose a random 128 bit number, then start looking at every odd number greater than that number and run primality tests on it to see if it is prime. To have it be secure your random number has to truly be random. For instance if you run this client side in javascript to send a password over, I am guessing it is not going to be secure.

Here is a discussion of primality tests

http://en.wikipedia.org/wiki/Primality_test