org.h2.util
Class RandomUtils

java.lang.Object
  extended by org.h2.util.RandomUtils

public class RandomUtils
extends java.lang.Object

Utility class that supports random and secure random functions. In some systems SecureRandom initialization is very slow, a workaround is implemented here.


Method Summary
static byte[] getSecureBytes(int len)
          Get a number of cryptographically secure pseudo random bytes.
static long getSecureLong()
          Get a cryptographically secure pseudo random long value.
static int nextInt(int lowerThan)
          Get a pseudo random int value between 0 (including and the given value (excluding).
static int nextSecureInt(int lowerThan)
          Get a cryptographically secure pseudo random int value between 0 (including and the given value (excluding).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSecureLong

public static long getSecureLong()
Get a cryptographically secure pseudo random long value.

Returns:
the random long value

getSecureBytes

public static byte[] getSecureBytes(int len)
Get a number of cryptographically secure pseudo random bytes.

Parameters:
len - the number of bytes
Returns:
the random bytes

nextInt

public static int nextInt(int lowerThan)
Get a pseudo random int value between 0 (including and the given value (excluding). The value is not cryptographically secure.

Parameters:
lowerThan - the value returned will be lower than this value
Returns:
the random long value

nextSecureInt

public static int nextSecureInt(int lowerThan)
Get a cryptographically secure pseudo random int value between 0 (including and the given value (excluding).

Parameters:
lowerThan - the value returned will be lower than this value
Returns:
the random long value