Package net.storm.api.commons
Class Rand
java.lang.Object
net.storm.api.commons.Rand
Provides cryptographically secure random number generation utilities.
This class uses SecureRandom with the SHA1PRNG algorithm to
generate random values. All methods are synchronized to ensure thread-safety.
Unlike IntRandomNumberGenerator, this class provides a static
utility interface and uses cryptographically secure randomization, making
it suitable for security-sensitive operations.
Example usage:
// Generate a random integer in a range
int randomDelay = Rand.nextInt(500, 1500);
// Generate any random integer
int randomValue = Rand.nextInt();
// Generate a random boolean
if (Rand.nextBool()) {
// 50% chance of executing this block
}
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Rand
public Rand()
-
-
Method Details
-
nextInt
public static int nextInt(int min, int max) Returns a random integer within the specified inclusive range.This method is thread-safe and uses cryptographically secure randomization.
- Parameters:
min- the minimum value (inclusive)max- the maximum value (inclusive)- Returns:
- a random integer between min and max (inclusive)
-
nextInt
public static int nextInt()Returns a random integer from the full range of possible integer values.This method is thread-safe and uses cryptographically secure randomization.
- Returns:
- a random integer value
-
nextBool
public static boolean nextBool()Returns a random boolean value.This method is thread-safe and uses cryptographically secure randomization. It has an equal probability of returning
trueorfalse.- Returns:
- a random boolean value
-