Class PRNG
java.lang.Object
io.vertx.ext.auth.prng.PRNG
- All Implemented Interfaces:
VertxContextPRNG
Wrapper around secure random that periodically seeds the PRNG with new entropy. To avoid entropy exhaustion
the entropy is only refreshed if the PRNG is used. This introduces a new variable which reduces the probability
of cracking the random number generator.
- Author:
- Paulo Lopes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()stop seeding the PRNGbooleanReturns a secure random booleanvoidnextBytes(byte[] bytes) Fills the given byte array with random bytes.doubleReturns a secure random double value.floatReturns a secure random float value.doubleReturns a secure random double value.intnextInt()Returns a secure random intintnextInt(int bound) Returns a secure random int, between 0 (inclusive) and the specified bound (exclusive).longnextLong()Returns a secure random longnextString(int length) Returns a Base64 url encoded String of random data with the given length.
-
Constructor Details
-
PRNG
-
-
Method Details
-
close
public void close()Description copied from interface:VertxContextPRNGstop seeding the PRNG- Specified by:
closein interfaceVertxContextPRNG
-
nextBytes
public void nextBytes(byte[] bytes) Description copied from interface:VertxContextPRNGFills the given byte array with random bytes.- Specified by:
nextBytesin interfaceVertxContextPRNG- Parameters:
bytes- a byte array.
-
nextInt
public int nextInt()Description copied from interface:VertxContextPRNGReturns a secure random int- Specified by:
nextIntin interfaceVertxContextPRNG- Returns:
- random int.
-
nextInt
public int nextInt(int bound) Description copied from interface:VertxContextPRNGReturns a secure random int, between 0 (inclusive) and the specified bound (exclusive).- Specified by:
nextIntin interfaceVertxContextPRNG- Parameters:
bound- the upper bound (exclusive), which must be positive.- Returns:
- random int.
-
nextBoolean
public boolean nextBoolean()Description copied from interface:VertxContextPRNGReturns a secure random boolean- Specified by:
nextBooleanin interfaceVertxContextPRNG- Returns:
- random boolean.
-
nextLong
public long nextLong()Description copied from interface:VertxContextPRNGReturns a secure random long- Specified by:
nextLongin interfaceVertxContextPRNG- Returns:
- random long.
-
nextFloat
public float nextFloat()Description copied from interface:VertxContextPRNGReturns a secure random float value. The value is uniformly distributed between 0.0 and 1.0- Specified by:
nextFloatin interfaceVertxContextPRNG- Returns:
- random float.
-
nextDouble
public double nextDouble()Description copied from interface:VertxContextPRNGReturns a secure random double value. The value is uniformly distributed between 0.0 and 1.0- Specified by:
nextDoublein interfaceVertxContextPRNG- Returns:
- random double.
-
nextGaussian
public double nextGaussian()Description copied from interface:VertxContextPRNGReturns a secure random double value. The value is Gaussian ("normally") distributed with mean 0.0 and standard deviation 1.0- Specified by:
nextGaussianin interfaceVertxContextPRNG- Returns:
- random double.
-
nextString
Description copied from interface:VertxContextPRNGReturns a Base64 url encoded String of random data with the given length. The length parameter refers to the length of the String before the encoding step.- Specified by:
nextStringin interfaceVertxContextPRNG- Parameters:
length- the desired string length before Base64 encoding.- Returns:
- A base 64 encoded string.
-