Java BigInteger(int bitLength, int certainty, Random rnd) Constructor
Syntax
BigInteger(int bitLength, int certainty, Random rnd) constructor from BigInteger has the following syntax.
public BigInteger(int bitLength, int certainty, Random rnd)
Example
In the following code shows how to use BigInteger.BigInteger(int bitLength, int certainty, Random rnd) constructor.
import java.math.BigInteger;
import java.security.SecureRandom;
/*w w w .j a v a 2 s .c o m*/
public class Main {
public static void main(String[] args) throws Exception {
int bitLength = 512; // 512 bits
SecureRandom rnd = new SecureRandom();
int certainty = 90; // 1 - 1/2(90) certainty
BigInteger mod = new BigInteger(bitLength, certainty, rnd);
System.out.println(mod);
}
}
The code above generates the following result.