Package com.goterl.lazysodium.interfaces
Interface Random
- All Known Implementing Classes:
LazySodium,LazySodiumJava
public interface Random
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbyte[]nonce(int size) Get a random number of bytes to use in a nonce.voidrandomBytesBuf(byte[] buff, int size) Fill a buffer with random bytes.byte[]randomBytesBuf(int size) Get a random number of bytes.voidrandomBytesDeterministic(byte[] buff, int size, byte[] seed) Fill a buffer with deterministically random bytes given a seed.byte[]randomBytesDeterministic(int size, byte[] seed) Get deterministically random bytes given a seed.longReturn a unsigned int byte 0 and 0xffffffff included.longrandomBytesUniform(int upperBound) Returns an unpredictable value between 0 and upperBound (excluded).
-
Field Details
-
BYTES_MAX
static final long BYTES_MAX- See Also:
-
SEEDBYTES
static final int SEEDBYTES- See Also:
-
-
Method Details
-
randomBytesRandom
long randomBytesRandom()Return a unsigned int byte 0 and 0xffffffff included.- Returns:
- A random integer.
-
randomBytesUniform
long randomBytesUniform(int upperBound) Returns an unpredictable value between 0 and upperBound (excluded). Unlike randombytes_random() % upper_bound, it guarantees a uniform distribution of the possible output values even when upper_bound is not a power of 2. Note that an upper_bound less than 2 leaves only a single element to be chosen, namely 0.- Parameters:
upperBound- Upper bound (exclusive)- Returns:
- A uniformly random unsigned int.
-
randomBytesBuf
void randomBytesBuf(byte[] buff, int size) Fill a buffer with random bytes.- Parameters:
buff- Buffer to fill.size- The number of bytes in the array to fill with random bytes.
-
randomBytesBuf
byte[] randomBytesBuf(int size) Get a random number of bytes.- Parameters:
size- The length of the byte array to return.- Returns:
- Random byte array.
-
randomBytesDeterministic
void randomBytesDeterministic(byte[] buff, int size, byte[] seed) Fill a buffer with deterministically random bytes given a seed.- Parameters:
buff- Buffer to fillsize- The number of bytes in the array to fill with random bytes.seed- Seed to provide.
-
randomBytesDeterministic
byte[] randomBytesDeterministic(int size, byte[] seed) Get deterministically random bytes given a seed.- Parameters:
size- Size of byte array to return.seed- Seed to provide.- Returns:
- Deterministically random byte array.
-
nonce
byte[] nonce(int size) Get a random number of bytes to use in a nonce.- Parameters:
size- The size of the byte array to return.- Returns:
- Random nonce array.
- See Also:
-