How do I generate a 160 bit prime number in java?
问题 I want to generate a 160-bit prime number in java. I know that I'll have to loop through all the 160-bit numbers and for any number n , I'll have to check if they are divisible by any primes less than sqroot(n) or by any primality test like Miller-Rabin test . My questions are: Is there any specific library which does this? Is there any other (better) way to do this? 回答1: BigInteger.probablePrime(160, new Random()) generates a BigInteger that is almost certainly prime -- the probability that