static TBigInteger consBigInteger(int bitLength,int certainty,Random rnd){
  if (bitLength <= 10) {
    int rp[]=offsetPrimes[bitLength];
    return BIprimes[rp[0] + rnd.nextInt(rp[1])];
  }
  int shiftCount=(-bitLength) & 31;
  int last=(bitLength + 31) >> 5;
  TBigInteger n=new TBigInteger(1,last,new int[last]);
  last--;
  do {
    for (int i=0; i < n.numberLength; i++) {
      n.digits[i]=rnd.nextInt();
    }
    n.digits[last]|=0x80000000;
    n.digits[last]>>>=shiftCount;
    n.digits[0]|=1;
  }
 while (!isProbablePrime(n,certainty));
  return n;
}

static TBigInteger consBigInteger ( int bitLength , int certainty , Random rnd ) { if ( bitLength <= 10 ) { int rp [ ] = offsetPrimes [ bitLength ] ; return BIprimes [ rp [ 0 ] + rnd . nextInt ( rp [ 1 ] ) ] ; } int shiftCount = ( - bitLength ) & 31 ; int last = ( bitLength + 31 ) > > 5 ; TBigInteger n = new TBigInteger ( 1 , last , new int [ last ] ) ; last -- ; do { for ( int i = 0 ; i < n . numberLength ; i ++ ) { n . digits [ i ] = rnd . nextInt ( ) ; } n . digits [ last ] |= 0x80000000 ; n . digits [ last ] >>>= shiftCount ; n . digits [ 0 ] |= 1 ; } while ( ! isProbablePrime ( n , certainty ) ) ; return n ; }
a random number is generated until a probable prime number is found .
