jeudi 26 février 2015

RSA Encryption - Finding P and Q



I'm trying to figure out an RSA Encryption (using Java) by finding out P and Q. Here is what I have to do:


I have to generate two random numbers (P and Q) and following the guidelines:



  1. P & Q has to be at the most 7 bits long

  2. P & Q cannot be 0 or 1 (Using the Math.random() function is what I'm doing for this step)

  3. P & Q must be primes

  4. P & Q cannot be the same number (Already have this figured out)

  5. (PQ) must be at least 256 (Already have this figured out)


So, basically I'm starting out with this:



double p = Math.random();
double q = Math.random();


... and then trying to follow the 5 guidelines above. Can anyone give me a hint on how to figure out #1 and #3?


Thanks!




Aucun commentaire:

Enregistrer un commentaire