public interface VertxContextPRNG
When applicable, use of VertxContextPRNG rather than create new PRNG objects is helpful to keep the system entropy usage to the minimum avoiding potential blocking across the application.
The use of VertxContextPRNG is particularly appropriate when multiple handlers use random numbers.
Modifier and Type | Method and Description |
---|---|
static VertxContextPRNG |
current()
Get or create a secure non blocking random number generator using the current vert.x context.
|
static VertxContextPRNG |
current(Context context)
Get or create a secure non blocking random number generator using the provided vert.x context.
|
static VertxContextPRNG |
current(Vertx vertx)
Get or create a secure non blocking random number generator using the current vert.x instance.
|
void |
nextBytes(byte[] bytes)
Fills the given byte array with random bytes.
|
int |
nextInt()
Returns a secure random int
|
int |
nextInt(int bound)
Returns a secure random int, between 0 (inclusive) and the specified bound (exclusive).
|
default String |
nextString(int length)
Returns a Base64 mime encoded String of random data with the given length.
|
static VertxContextPRNG current()
IllegalStateException
is thrown.IllegalStateException
- when there is no context available.static VertxContextPRNG current(Context context)
context
- a Vert.x context.static VertxContextPRNG current(Vertx vertx)
vertx
- a Vert.x instance.void nextBytes(byte[] bytes)
bytes
- a byte array.default String nextString(int length)
length
- the desired string length before Base64 encoding.int nextInt()
int nextInt(int bound)
bound
- the upper bound (exclusive), which must be positive.Copyright © 2023 Eclipse. All rights reserved.