Code example for BigInteger

Methods: mod

0
   * 
   * @param r Generate an integer between 0 and r-1 inclusive. 
   */ 
  public static BigInteger generateBigIntegerLessThan(BigInteger r) {
    int maxBytes = (int) Math.ceil(((double) r.bitLength()) / 8);
    BigInteger randInt = new BigInteger(generateRandomBytes(maxBytes));
    return randInt.mod(r);
  } 
 
  /* 
   * Helper to reseed the shared secure random number generator. 
   */ 
  public static void reseedSharedRandom() { 
    sharedSecureRandom.setSeed(sharedSecureRandom.generateSeed(8));
  } 
 
  /* 
   * Helper to convert Byte Array to a Hex String 
   * Input: byte[] array 
   * Output: Hex string 
   */