Package com.goterl.lazysodium.interfaces
Interface Random
-
- All Known Implementing Classes:
LazySodium,LazySodiumJava
public interface Random
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]nonce(int size)Get a random number of bytes to use in a nonce.byte[]randomBytesBuf(int size)Get a random number of bytes.byte[]randomBytesDeterministic(int size, byte[] seed)Get deterministically random bytes given a seed.longrandomBytesRandom()Return a unsigned int byte 0 and 0xffffffff included.longrandomBytesUniform(int upperBound)Returns an unpredictable value between 0 and upperBound (excluded).
-
-
-
Method Detail
-
randomBytesRandom
long randomBytesRandom()
Return a unsigned int byte 0 and 0xffffffff included.- Returns:
- A random byte.
-
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-- Returns:
- A uniformly random unsigned int.
-
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
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:
randomBytesBuf(int)
-
-